idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
26,600 | public function options ( $ commandName , $ subCommandName = '' ) { $ Shell = $ this -> getShell ( $ commandName ) ; if ( ! $ Shell ) { return [ ] ; } $ parser = $ Shell -> getOptionParser ( ) ; if ( ! empty ( $ subCommandName ) ) { $ subCommandName = Inflector :: camelize ( $ subCommandName ) ; if ( $ Shell -> hasTask... | Get options list for the given command or subcommand |
26,601 | public static function delimit ( $ string , $ delimiter = '_' ) { $ cacheKey = __FUNCTION__ . $ delimiter ; $ result = static :: _cache ( $ cacheKey , $ string ) ; if ( $ result === false ) { $ result = mb_strtolower ( preg_replace ( '/(?<=\\w)([A-Z])/' , $ delimiter . '\\1' , $ string ) ) ; static :: _cache ( $ cacheK... | Expects a CamelCasedInputString and produces a lower_case_delimited_string |
26,602 | public function match ( array $ url , array $ context = [ ] ) { if ( empty ( $ this -> _compiledRoute ) ) { $ this -> compile ( ) ; } if ( isset ( $ url [ '_entity' ] ) ) { $ entity = $ url [ '_entity' ] ; $ this -> _checkEntity ( $ entity ) ; foreach ( $ this -> keys as $ field ) { if ( ! isset ( $ url [ $ field ] ) &... | Match by entity and map its fields to the URL pattern by comparing the field names with the template vars . |
26,603 | protected function _checkEntity ( $ entity ) { if ( ! $ entity instanceof ArrayAccess && ! is_array ( $ entity ) ) { throw new RuntimeException ( sprintf ( 'Route `%s` expects the URL option `_entity` to be an array or object implementing \ArrayAccess, but `%s` passed.' , $ this -> template , getTypeName ( $ entity ) )... | Checks that we really deal with an entity object |
26,604 | public function options ( ) { $ commandName = $ subCommandName = '' ; if ( ! empty ( $ this -> args [ 0 ] ) ) { $ commandName = $ this -> args [ 0 ] ; } if ( ! empty ( $ this -> args [ 1 ] ) ) { $ subCommandName = $ this -> args [ 1 ] ; } $ options = $ this -> Command -> options ( $ commandName , $ subCommandName ) ; r... | list options for the named command |
26,605 | public function subcommands ( ) { if ( ! $ this -> args ) { return $ this -> _output ( ) ; } $ options = $ this -> Command -> subCommands ( $ this -> args [ 0 ] ) ; return $ this -> _output ( $ options ) ; } | list subcommands for the named command |
26,606 | public function beforeDispatch ( Event $ event ) { $ request = $ event -> getData ( 'request' ) ; $ locale = Locale :: acceptFromHttp ( $ request -> getHeaderLine ( 'Accept-Language' ) ) ; if ( ! $ locale || ( ! empty ( $ this -> _locales ) && ! in_array ( $ locale , $ this -> _locales ) ) ) { return ; } I18n :: setLoc... | Inspects the request for the Accept - Language header and sets the Locale for the current runtime if it matches the list of valid locales as passed in the configuration . |
26,607 | public function toAtom ( $ dateString , $ timezone = null ) { $ timezone = $ this -> _getTimezone ( $ timezone ) ? : date_default_timezone_get ( ) ; return ( new Time ( $ dateString ) ) -> timezone ( $ timezone ) -> toAtomString ( ) ; } | Returns a date formatted for Atom RSS feeds . |
26,608 | public function toRss ( $ dateString , $ timezone = null ) { $ timezone = $ this -> _getTimezone ( $ timezone ) ? : date_default_timezone_get ( ) ; return ( new Time ( $ dateString ) ) -> timezone ( $ timezone ) -> toRssString ( ) ; } | Formats date for RSS feeds |
26,609 | public function timeAgoInWords ( $ dateTime , array $ options = [ ] ) { $ element = null ; $ options += [ 'element' => null , 'timezone' => null ] ; $ options [ 'timezone' ] = $ this -> _getTimezone ( $ options [ 'timezone' ] ) ; if ( $ options [ 'timezone' ] ) { $ dateTime = $ dateTime -> timezone ( $ options [ 'timez... | Formats a date into a phrase expressing the relative time . |
26,610 | public function wasWithinLast ( $ timeInterval , $ dateString , $ timezone = null ) { return ( new Time ( $ dateString , $ timezone ) ) -> wasWithinLast ( $ timeInterval ) ; } | Returns true if specified datetime was within the interval specified else false . |
26,611 | public function isWithinNext ( $ timeInterval , $ dateString , $ timezone = null ) { return ( new Time ( $ dateString , $ timezone ) ) -> isWithinNext ( $ timeInterval ) ; } | Returns true if specified datetime is within the interval specified else false . |
26,612 | public function read ( $ key ) { $ file = $ this -> _getFilePath ( $ key , true ) ; $ contents = parse_ini_file ( $ file , true ) ; if ( $ this -> _section && isset ( $ contents [ $ this -> _section ] ) ) { $ values = $ this -> _parseNestedValues ( $ contents [ $ this -> _section ] ) ; } else { $ values = [ ] ; foreach... | Read an ini file and return the results as an array . |
26,613 | protected function _parseNestedValues ( $ values ) { foreach ( $ values as $ key => $ value ) { if ( $ value === '1' ) { $ value = true ; } if ( $ value === '' ) { $ value = false ; } unset ( $ values [ $ key ] ) ; if ( strpos ( $ key , '.' ) !== false ) { $ values = Hash :: insert ( $ values , $ key , $ value ) ; } el... | parses nested values out of keys . |
26,614 | public function dump ( $ key , array $ data ) { $ result = [ ] ; foreach ( $ data as $ k => $ value ) { $ isSection = false ; if ( $ k [ 0 ] !== '[' ) { $ result [ ] = "[$k]" ; $ isSection = true ; } if ( is_array ( $ value ) ) { $ kValues = Hash :: flatten ( $ value , '.' ) ; foreach ( $ kValues as $ k2 => $ v ) { $ r... | Dumps the state of Configure data into an ini formatted string . |
26,615 | protected function _value ( $ value ) { if ( $ value === null ) { return 'null' ; } if ( $ value === true ) { return 'true' ; } if ( $ value === false ) { return 'false' ; } return ( string ) $ value ; } | Converts a value into the ini equivalent |
26,616 | protected function _isDisabled ( $ radio , $ disabled ) { if ( ! $ disabled ) { return false ; } if ( $ disabled === true ) { return true ; } $ isNumeric = is_numeric ( $ radio [ 'value' ] ) ; return ( ! is_array ( $ disabled ) || in_array ( ( string ) $ radio [ 'value' ] , $ disabled , ! $ isNumeric ) ) ; } | Disabled attribute detection . |
26,617 | public function add ( $ params , $ types = [ ] , $ prepend = false ) { $ put = $ prepend ? 'array_unshift' : 'array_push' ; $ typeMap = $ this -> getTypeMap ( ) -> setTypes ( $ types ) ; foreach ( $ params as $ k => $ p ) { if ( $ p === 'literal' ) { $ put ( $ this -> _conditions , $ k ) ; continue ; } if ( $ p === 'id... | Adds one or more arguments for the function call . |
26,618 | public function getOptionParser ( ) { list ( $ root , $ name ) = explode ( ' ' , $ this -> name , 2 ) ; $ parser = new ConsoleOptionParser ( $ name ) ; $ parser -> setRootName ( $ root ) ; $ parser = $ this -> buildOptionParser ( $ parser ) ; if ( ! ( $ parser instanceof ConsoleOptionParser ) ) { throw new RuntimeExcep... | Get the option parser . |
26,619 | protected function displayHelp ( ConsoleOptionParser $ parser , Arguments $ args , ConsoleIo $ io ) { $ format = 'text' ; if ( $ args -> getArgumentAt ( 0 ) === 'xml' ) { $ format = 'xml' ; $ io -> setOutputAs ( ConsoleOutput :: RAW ) ; } $ io -> out ( $ parser -> help ( null , $ format ) ) ; } | Output help content |
26,620 | protected function setOutputLevel ( Arguments $ args , ConsoleIo $ io ) { $ io -> setLoggers ( ConsoleIo :: NORMAL ) ; if ( $ args -> getOption ( 'quiet' ) ) { $ io -> level ( ConsoleIo :: QUIET ) ; $ io -> setLoggers ( ConsoleIo :: QUIET ) ; } if ( $ args -> getOption ( 'verbose' ) ) { $ io -> level ( ConsoleIo :: VER... | Set the output level based on the Arguments . |
26,621 | protected function _mergeProperty ( $ property , $ parentClasses , $ options ) { $ thisValue = $ this -> { $ property } ; $ isAssoc = false ; if ( isset ( $ options [ 'associative' ] ) && in_array ( $ property , ( array ) $ options [ 'associative' ] ) ) { $ isAssoc = true ; } if ( $ isAssoc ) { $ thisValue = Hash :: no... | Merge a single property with the values declared in all parent classes . |
26,622 | protected function _mergePropertyData ( $ current , $ parent , $ isAssoc ) { if ( ! $ isAssoc ) { return array_merge ( $ parent , $ current ) ; } $ parent = Hash :: normalize ( $ parent ) ; foreach ( $ parent as $ key => $ value ) { if ( ! isset ( $ current [ $ key ] ) ) { $ current [ $ key ] = $ value ; } } return $ c... | Merge each of the keys in a property together . |
26,623 | public function setReferrerPolicy ( $ policy = self :: SAME_ORIGIN ) { $ available = [ self :: NO_REFERRER , self :: NO_REFERRER_WHEN_DOWNGRADE , self :: ORIGIN , self :: ORIGIN_WHEN_CROSS_ORIGIN , self :: SAME_ORIGIN , self :: STRICT_ORIGIN , self :: STRICT_ORIGIN_WHEN_CROSS_ORIGIN , self :: UNSAFE_URL , ] ; $ this ->... | Referrer - Policy |
26,624 | public function setXFrameOptions ( $ option = self :: SAMEORIGIN , $ url = null ) { $ this -> checkValues ( $ option , [ self :: DENY , self :: SAMEORIGIN , self :: ALLOW_FROM ] ) ; if ( $ option === self :: ALLOW_FROM ) { if ( empty ( $ url ) ) { throw new InvalidArgumentException ( 'The 2nd arg $url can not be empty ... | X - Frame - Options |
26,625 | public function setXssProtection ( $ mode = self :: XSS_BLOCK ) { $ mode = ( string ) $ mode ; if ( $ mode === self :: XSS_BLOCK ) { $ mode = self :: XSS_ENABLED_BLOCK ; } $ this -> checkValues ( $ mode , [ self :: XSS_ENABLED , self :: XSS_DISABLED , self :: XSS_ENABLED_BLOCK ] ) ; $ this -> headers [ 'x-xss-protectio... | X - XSS - Protection |
26,626 | public function setCrossDomainPolicy ( $ policy = self :: ALL ) { $ this -> checkValues ( $ policy , [ self :: ALL , self :: NONE , self :: MASTER_ONLY , self :: BY_CONTENT_TYPE , self :: BY_FTP_FILENAME , ] ) ; $ this -> headers [ 'x-permitted-cross-domain-policies' ] = $ policy ; return $ this ; } | X - Permitted - Cross - Domain - Policies |
26,627 | protected function checkValues ( $ value , array $ allowed ) { if ( ! in_array ( $ value , $ allowed ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid arg `%s`, use one of these: %s' , $ value , implode ( ', ' , $ allowed ) ) ) ; } } | Convenience method to check if a value is in the list of allowed args |
26,628 | public function elem ( $ name , $ attrib = [ ] , $ content = null , $ endTag = true ) { $ namespace = null ; if ( isset ( $ attrib [ 'namespace' ] ) ) { $ namespace = $ attrib [ 'namespace' ] ; unset ( $ attrib [ 'namespace' ] ) ; } $ cdata = false ; if ( is_array ( $ content ) && isset ( $ content [ 'cdata' ] ) ) { $ ... | Generates an XML element |
26,629 | public function rewind ( ) { if ( $ this -> _index == 0 ) { return ; } if ( ! $ this -> _useBuffering ) { $ msg = 'You cannot rewind an un-buffered ResultSet. Use Query::bufferResults() to get a buffered ResultSet.' ; throw new Exception ( $ msg ) ; } $ this -> _index = 0 ; } | Rewinds a ResultSet . |
26,630 | public function first ( ) { foreach ( $ this as $ result ) { if ( $ this -> _statement && ! $ this -> _useBuffering ) { $ this -> _statement -> closeCursor ( ) ; } return $ result ; } } | Get the first record from a result set . |
26,631 | public function serialize ( ) { if ( ! $ this -> _useBuffering ) { $ msg = 'You cannot serialize an un-buffered ResultSet. Use Query::bufferResults() to get a buffered ResultSet.' ; throw new Exception ( $ msg ) ; } while ( $ this -> valid ( ) ) { $ this -> next ( ) ; } if ( $ this -> _results instanceof SplFixedArray ... | Serializes a resultset . |
26,632 | public function unserialize ( $ serialized ) { $ results = ( array ) ( unserialize ( $ serialized ) ? : [ ] ) ; $ this -> _results = SplFixedArray :: fromArray ( $ results ) ; $ this -> _useBuffering = true ; $ this -> _count = $ this -> _results -> count ( ) ; } | Unserializes a resultset . |
26,633 | public function count ( ) { if ( $ this -> _count !== null ) { return $ this -> _count ; } if ( $ this -> _statement ) { return $ this -> _count = $ this -> _statement -> rowCount ( ) ; } if ( $ this -> _results instanceof SplFixedArray ) { $ this -> _count = $ this -> _results -> count ( ) ; } else { $ this -> _count ... | Gives the number of rows in the result set . |
26,634 | protected function _calculateAssociationMap ( $ query ) { $ map = $ query -> getEagerLoader ( ) -> associationsMap ( $ this -> _defaultTable ) ; $ this -> _matchingMap = ( new Collection ( $ map ) ) -> match ( [ 'matching' => true ] ) -> indexBy ( 'alias' ) -> toArray ( ) ; $ this -> _containMap = ( new Collection ( ar... | Calculates the list of associations that should get eager loaded when fetching each record |
26,635 | protected function _calculateColumnMap ( $ query ) { $ map = [ ] ; foreach ( $ query -> clause ( 'select' ) as $ key => $ field ) { $ key = trim ( $ key , '"`[]' ) ; if ( strpos ( $ key , '__' ) <= 0 ) { $ map [ $ this -> _defaultAlias ] [ $ key ] = $ key ; continue ; } $ parts = explode ( '__' , $ key , 2 ) ; $ map [ ... | Creates a map of row keys out of the query select clause that can be used to hydrate nested result sets more quickly . |
26,636 | protected function _getTypes ( $ table , $ fields ) { $ types = [ ] ; $ schema = $ table -> getSchema ( ) ; $ map = array_keys ( ( array ) Type :: getMap ( ) + [ 'string' => 1 , 'text' => 1 , 'boolean' => 1 ] ) ; $ typeMap = array_combine ( $ map , array_map ( [ 'Cake\Database\Type' , 'build' ] , $ map ) ) ; foreach ( ... | Returns the Type classes for each of the passed fields belonging to the table . |
26,637 | protected function _fetchResult ( ) { if ( ! $ this -> _statement ) { return false ; } $ row = $ this -> _statement -> fetch ( 'assoc' ) ; if ( $ row === false ) { return $ row ; } return $ this -> _groupResult ( $ row ) ; } | Helper function to fetch the next result from the statement or seeded results . |
26,638 | public function returnType ( $ type = null ) { deprecationWarning ( 'TypedResultTrait::returnType() is deprecated. ' . 'Use TypedResultTrait::setReturnType()/getReturnType() instead.' ) ; if ( $ type !== null ) { $ this -> _returnType = $ type ; return $ this ; } return $ this -> _returnType ; } | Sets the type of the value this object will generate . If called without arguments returns the current known type |
26,639 | public function render ( $ view = null , $ layout = null ) { $ return = parent :: render ( $ view , $ layout ) ; if ( ! empty ( $ this -> viewVars [ '_jsonp' ] ) ) { $ jsonpParam = $ this -> viewVars [ '_jsonp' ] ; if ( $ this -> viewVars [ '_jsonp' ] === true ) { $ jsonpParam = 'callback' ; } if ( $ this -> request ->... | Render a JSON view . |
26,640 | protected function _serialize ( $ serialize ) { $ data = $ this -> _dataToSerialize ( $ serialize ) ; $ jsonOptions = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PARTIAL_OUTPUT_ON_ERROR ; if ( isset ( $ this -> viewVars [ '_jsonOptions' ] ) ) { if ( $ this -> viewVars [ '_jsonOptions' ] === false... | Serialize view vars |
26,641 | protected function _literalArgumentFunction ( $ name , $ expression , $ types = [ ] , $ return = 'string' ) { if ( ! is_string ( $ expression ) ) { $ expression = [ $ expression ] ; } else { $ expression = [ $ expression => 'literal' ] ; } return $ this -> _build ( $ name , $ expression , $ types , $ return ) ; } | Helper function to build a function expression that only takes one literal argument . |
26,642 | public function sum ( $ expression , $ types = [ ] ) { $ returnType = 'float' ; if ( current ( $ types ) === 'integer' ) { $ returnType = 'integer' ; } return $ this -> _literalArgumentFunction ( 'SUM' , $ expression , $ types , $ returnType ) ; } | Returns a FunctionExpression representing a call to SQL SUM function . |
26,643 | public function extract ( $ part , $ expression , $ types = [ ] ) { $ expression = $ this -> _literalArgumentFunction ( 'EXTRACT' , $ expression , $ types , 'integer' ) ; $ expression -> setConjunction ( ' FROM' ) -> add ( [ $ part => 'literal' ] , [ ] , true ) ; return $ expression ; } | Returns the specified date part from the SQL expression . |
26,644 | public function dateAdd ( $ expression , $ value , $ unit , $ types = [ ] ) { if ( ! is_numeric ( $ value ) ) { $ value = 0 ; } $ interval = $ value . ' ' . $ unit ; $ expression = $ this -> _literalArgumentFunction ( 'DATE_ADD' , $ expression , $ types , 'datetime' ) ; $ expression -> setConjunction ( ', INTERVAL' ) -... | Add the time unit to the date expression |
26,645 | public function now ( $ type = 'datetime' ) { if ( $ type === 'datetime' ) { return $ this -> _build ( 'NOW' ) -> setReturnType ( 'datetime' ) ; } if ( $ type === 'date' ) { return $ this -> _build ( 'CURRENT_DATE' ) -> setReturnType ( 'date' ) ; } if ( $ type === 'time' ) { return $ this -> _build ( 'CURRENT_TIME' ) -... | Returns a FunctionExpression representing a call that will return the current date and time . By default it returns both date and time but you can also make it generate only the date or only the time . |
26,646 | public function beforeDispatch ( Event $ event ) { $ request = $ event -> getData ( 'request' ) ; $ response = $ event -> getData ( 'response' ) ; $ event -> setData ( 'controller' , $ this -> _getController ( $ request , $ response ) ) ; } | Resolve the request parameters into a controller and attach the controller to the event object . |
26,647 | protected function addHeaders ( array $ headers ) { foreach ( $ headers as $ key => $ val ) { $ normalized = strtolower ( $ key ) ; $ this -> headers [ $ key ] = ( array ) $ val ; $ this -> headerNames [ $ normalized ] = $ key ; } } | Add an array of headers to the request . |
26,648 | public function isUnique ( array $ fields , $ message = null ) { $ options = [ ] ; if ( is_array ( $ message ) ) { $ options = $ message + [ 'message' => null ] ; $ message = $ options [ 'message' ] ; unset ( $ options [ 'message' ] ) ; } if ( ! $ message ) { if ( $ this -> _useI18n ) { $ message = __d ( 'cake' , 'This... | Returns a callable that can be used as a rule for checking the uniqueness of a value in the table . |
26,649 | public function existsIn ( $ field , $ table , $ message = null ) { $ options = [ ] ; if ( is_array ( $ message ) ) { $ options = $ message + [ 'message' => null ] ; $ message = $ options [ 'message' ] ; unset ( $ options [ 'message' ] ) ; } if ( ! $ message ) { if ( $ this -> _useI18n ) { $ message = __d ( 'cake' , 'T... | Returns a callable that can be used as a rule for checking that the values extracted from the entity to check exist as the primary key in another table . |
26,650 | public function validCount ( $ field , $ count = 0 , $ operator = '>' , $ message = null ) { if ( ! $ message ) { if ( $ this -> _useI18n ) { $ message = __d ( 'cake' , 'The count does not match {0}{1}' , [ $ operator , $ count ] ) ; } else { $ message = sprintf ( 'The count does not match %s%d' , $ operator , $ count ... | Validates the count of associated records . |
26,651 | public function canBeJoined ( $ possible = null ) { if ( $ possible !== null ) { deprecationWarning ( 'Using EagerLoadable::canBeJoined() as a setter is deprecated. ' . 'Use setCanBeJoined() instead.' ) ; $ this -> setCanBeJoined ( $ possible ) ; } return $ this -> _canBeJoined ; } | Gets whether or not this level can be fetched using a join . |
26,652 | public function config ( array $ config = null ) { deprecationWarning ( 'EagerLoadable::config() is deprecated. ' . 'Use setConfig()/getConfig() instead.' ) ; if ( $ config !== null ) { $ this -> setConfig ( $ config ) ; } return $ this -> getConfig ( ) ; } | Sets the list of options to pass to the association object for loading the records . |
26,653 | public function add ( $ conditions = [ ] , $ values = [ ] , $ types = [ ] ) { if ( ! is_array ( $ conditions ) ) { $ conditions = [ $ conditions ] ; } if ( ! is_array ( $ values ) ) { $ values = [ $ values ] ; } if ( ! is_array ( $ types ) ) { $ types = [ $ types ] ; } $ this -> _addExpressions ( $ conditions , $ value... | Adds one or more conditions and their respective true values to the case object . Conditions must be a one dimensional array or a QueryExpression . The trueValues must be a similar structure but may contain a string value . |
26,654 | protected function _addExpressions ( $ conditions , $ values , $ types ) { $ rawValues = array_values ( $ values ) ; $ keyValues = array_keys ( $ values ) ; foreach ( $ conditions as $ k => $ c ) { $ numericKey = is_numeric ( $ k ) ; if ( $ numericKey && empty ( $ c ) ) { continue ; } if ( ! $ c instanceof ExpressionIn... | Iterates over the passed in conditions and ensures that there is a matching true value for each . If no matching true value then it is defaulted to 1 . |
26,655 | protected function _compile ( $ part , ValueBinder $ generator ) { if ( $ part instanceof ExpressionInterface ) { $ part = $ part -> sql ( $ generator ) ; } elseif ( is_array ( $ part ) ) { $ placeholder = $ generator -> placeholder ( 'param' ) ; $ generator -> bind ( $ placeholder , $ part [ 'value' ] , $ part [ 'type... | Compiles the relevant parts into sql |
26,656 | public function sql ( ValueBinder $ generator ) { $ parts = [ ] ; $ parts [ ] = 'CASE' ; foreach ( $ this -> _conditions as $ k => $ part ) { $ value = $ this -> _values [ $ k ] ; $ parts [ ] = 'WHEN ' . $ this -> _compile ( $ part , $ generator ) . ' THEN ' . $ this -> _compile ( $ value , $ generator ) ; } if ( $ thi... | Converts the Node into a SQL string fragment . |
26,657 | protected function _create ( $ class , $ alias , $ settings ) { if ( is_callable ( $ class ) ) { $ class = $ class ( $ alias ) ; } if ( is_object ( $ class ) ) { $ instance = $ class ; } if ( ! isset ( $ instance ) ) { $ instance = new $ class ( $ settings ) ; } if ( $ instance instanceof LoggerInterface ) { return $ i... | Create the logger instance . |
26,658 | public function text ( $ width = 72 ) { $ parser = $ this -> _parser ; $ out = [ ] ; $ description = $ parser -> getDescription ( ) ; if ( ! empty ( $ description ) ) { $ out [ ] = Text :: wrap ( $ description , $ width ) ; $ out [ ] = '' ; } $ out [ ] = '<info>Usage:</info>' ; $ out [ ] = $ this -> _generateUsage ( ) ... | Get the help as formatted text suitable for output on the command line . |
26,659 | protected function _getMaxLength ( $ collection ) { $ max = 0 ; foreach ( $ collection as $ item ) { $ max = ( strlen ( $ item -> name ( ) ) > $ max ) ? strlen ( $ item -> name ( ) ) : $ max ; } return $ max ; } | Iterate over a collection and find the longest named thing . |
26,660 | public function xml ( $ string = true ) { $ parser = $ this -> _parser ; $ xml = new SimpleXMLElement ( '<shell></shell>' ) ; $ xml -> addChild ( 'command' , $ parser -> getCommand ( ) ) ; $ xml -> addChild ( 'description' , $ parser -> getDescription ( ) ) ; $ subcommands = $ xml -> addChild ( 'subcommands' ) ; foreac... | Get the help as an xml string . |
26,661 | protected function makeOptions ( ) { $ autoloadString = $ this -> param ( 'autoload' ) ? "'autoload' => true" : '' ; $ bootstrapString = $ this -> param ( 'bootstrap' ) ? "'bootstrap' => true" : '' ; $ routesString = $ this -> param ( 'routes' ) ? "'routes' => true" : '' ; return implode ( ', ' , array_filter ( [ $ aut... | Create options string for the load call . |
26,662 | protected function modifyApplication ( $ app , $ plugin , $ options ) { $ file = new File ( $ app , false ) ; $ contents = $ file -> read ( ) ; $ append = "\n \$this->addPlugin('%s', [%s]);\n" ; $ insert = str_replace ( ', []' , '' , sprintf ( $ append , $ plugin , $ options ) ) ; if ( ! preg_match ( '/function ... | Modify the application class |
26,663 | public function help ( $ width = 0 ) { $ default = $ short = '' ; if ( $ this -> _default && $ this -> _default !== true ) { $ default = sprintf ( ' <comment>(default: %s)</comment>' , $ this -> _default ) ; } if ( $ this -> _choices ) { $ default .= sprintf ( ' <comment>(choices: %s)</comment>' , implode ( '|' , $ thi... | Generate the help for this this option . |
26,664 | public function usage ( ) { $ name = ( strlen ( $ this -> _short ) > 0 ) ? ( '-' . $ this -> _short ) : ( '--' . $ this -> _name ) ; $ default = '' ; if ( strlen ( $ this -> _default ) > 0 && $ this -> _default !== true ) { $ default = ' ' . $ this -> _default ; } if ( $ this -> _choices ) { $ default = ' ' . implode (... | Get the usage value for this option |
26,665 | public function xml ( SimpleXMLElement $ parent ) { $ option = $ parent -> addChild ( 'option' ) ; $ option -> addAttribute ( 'name' , '--' . $ this -> _name ) ; $ short = '' ; if ( strlen ( $ this -> _short ) > 0 ) { $ short = '-' . $ this -> _short ; } $ option -> addAttribute ( 'short' , $ short ) ; $ option -> addA... | Append the option s xml into the parent . |
26,666 | protected function _stringifyValues ( $ generator ) { $ values = [ ] ; $ parts = $ this -> getValue ( ) ; if ( $ parts instanceof ExpressionInterface ) { return $ parts -> sql ( $ generator ) ; } foreach ( $ parts as $ i => $ value ) { if ( $ value instanceof ExpressionInterface ) { $ values [ ] = $ value -> sql ( $ ge... | Returns a string with the values as placeholders in a string to be used for the SQL version of this expression |
26,667 | public function traverse ( callable $ callable ) { foreach ( $ this -> getField ( ) as $ field ) { $ this -> _traverseValue ( $ field , $ callable ) ; } $ value = $ this -> getValue ( ) ; if ( $ value instanceof ExpressionInterface ) { $ callable ( $ value ) ; $ value -> traverse ( $ callable ) ; return ; } foreach ( $... | Traverses the tree of expressions stored in this object visiting first expressions in the left hand side and then the rest . |
26,668 | public function getControllerClass ( ServerRequest $ request ) { $ pluginPath = $ controller = null ; $ namespace = 'Controller' ; if ( $ request -> getParam ( 'controller' ) ) { $ controller = $ request -> getParam ( 'controller' ) ; } if ( $ request -> getParam ( 'plugin' ) ) { $ pluginPath = $ request -> getParam ( ... | Determine the controller class name based on current request and controller param |
26,669 | protected function missingController ( $ request ) { throw new MissingControllerException ( [ 'class' => $ request -> getParam ( 'controller' ) , 'plugin' => $ request -> getParam ( 'plugin' ) , 'prefix' => $ request -> getParam ( 'prefix' ) , '_ext' => $ request -> getParam ( '_ext' ) ] ) ; } | Throws an exception when a controller is missing . |
26,670 | public static function add_filter_to_form ( \ MoodleQuickForm & $ mform ) { $ options = [ 'multiple' => true ] ; $ filtername = self :: get_filter_name ( ) ; $ key = "filter_{$filtername}" ; $ mform -> addElement ( 'course' , $ key , get_string ( $ key , 'tool_usertours' ) , $ options ) ; $ mform -> setDefault ( $ key ... | Overrides the base add form element with a course selector . |
26,671 | public static function prepare_filter_values_for_form ( tour $ tour , \ stdClass $ data ) { $ filtername = static :: get_filter_name ( ) ; $ key = "filter_{$filtername}" ; $ values = $ tour -> get_filter_values ( $ filtername ) ; if ( empty ( $ values ) ) { $ values = 0 ; } $ data -> $ key = $ values ; return $ data ; ... | Overrides the base prepare the filter values for the form with an integer value . |
26,672 | public static function save_filter_values_from_form ( tour $ tour , \ stdClass $ data ) { $ filtername = static :: get_filter_name ( ) ; $ key = "filter_{$filtername}" ; $ newvalue = $ data -> $ key ; if ( empty ( $ data -> $ key ) ) { $ newvalue = [ ] ; } $ tour -> set_filter_values ( $ filtername , $ newvalue ) ; } | Overrides the base save the filter values from the form to the tour . |
26,673 | function prepare_package ( ) { global $ CFG ; $ writingleap = false ; if ( $ this -> exporter -> get ( 'formatclass' ) == PORTFOLIO_FORMAT_LEAP2A ) { $ leapwriter = $ this -> exporter -> get ( 'format' ) -> leap2a_writer ( ) ; $ writingleap = true ; } if ( $ this -> attachment ) { $ this -> copy_files ( array ( $ this ... | either a whole discussion a single post with or without attachment or just an attachment with no post |
26,674 | private function prepare_post_leap2a ( portfolio_format_leap2a_writer $ leapwriter , $ post , $ posthtml ) { $ entry = new portfolio_format_leap2a_entry ( 'forumpost' . $ post -> id , $ post -> subject , 'resource' , $ posthtml ) ; $ entry -> published = $ post -> created ; $ entry -> updated = $ post -> modified ; $ e... | helper function to add a leap2a entry element that corresponds to a single forum post including any attachments |
26,675 | private function prepare_post ( $ post , $ fileoutputextras = null ) { global $ DB ; static $ users ; if ( empty ( $ users ) ) { $ users = array ( $ this -> user -> id => $ this -> user ) ; } if ( ! array_key_exists ( $ post -> userid , $ users ) ) { $ users [ $ post -> userid ] = $ DB -> get_record ( 'user' , array ( ... | this is a very cut down version of what is in forum_make_mail_post |
26,676 | public function get_password_change_info ( stdClass $ user ) : array { $ site = get_site ( ) ; $ data = new stdClass ( ) ; $ data -> firstname = $ user -> firstname ; $ data -> lastname = $ user -> lastname ; $ data -> username = $ user -> username ; $ data -> sitename = format_string ( $ site -> fullname ) ; $ data ->... | Returns information on how the specified user can change their password . User accounts with authentication type set to nologin are disabled accounts . They cannot change their password . |
26,677 | public function get_logic_flags ( $ not ) { switch ( $ this -> op ) { case self :: OP_AND : case self :: OP_OR : $ negative = false ; break ; case self :: OP_NOT_AND : case self :: OP_NOT_OR : $ negative = true ; break ; default : throw new \ coding_exception ( 'Unknown operator' ) ; } switch ( $ this -> op ) { case se... | Converts the operator for the tree into two flags used for computing the result . |
26,678 | protected function recursive_get_all_children ( $ classname , array & $ result ) { foreach ( $ this -> children as $ child ) { if ( is_a ( $ child , $ classname ) ) { $ result [ ] = $ child ; } if ( $ child instanceof tree ) { $ child -> recursive_get_all_children ( $ classname , $ result ) ; } } } | Internal function that implements get_all_children efficiently . |
26,679 | public static function get_nested_json ( array $ children , $ op = self :: OP_AND ) { switch ( $ op ) { case self :: OP_AND : case self :: OP_NOT_OR : case self :: OP_OR : case self :: OP_NOT_AND : break ; default : throw new \ coding_exception ( 'Invalid $op' ) ; } $ result = new \ stdClass ( ) ; $ result -> op = $ op... | Returns a JSON object which corresponds to a tree . |
26,680 | public static function get_root_json ( array $ children , $ op = self :: OP_AND , $ show = true ) { $ result = self :: get_nested_json ( $ children , $ op ) ; switch ( $ op ) { case self :: OP_AND : case self :: OP_NOT_OR : $ multishow = true ; break ; case self :: OP_OR : case self :: OP_NOT_AND : $ multishow = false ... | Returns a JSON object which corresponds to a tree at root level . |
26,681 | private function executeCommand ( Server $ server ) { $ cmd = [ 'listIndexes' => $ this -> collectionName ] ; if ( isset ( $ this -> options [ 'maxTimeMS' ] ) ) { $ cmd [ 'maxTimeMS' ] = $ this -> options [ 'maxTimeMS' ] ; } try { $ cursor = $ server -> executeCommand ( $ this -> databaseName , new Command ( $ cmd ) , ... | Returns information for all indexes for this collection using the listIndexes command . |
26,682 | protected function get_target_suffix ( $ target ) { if ( empty ( $ target ) || $ target === RENDERER_TARGET_MAINTENANCE ) { if ( defined ( 'PREFERRED_RENDERER_TARGET' ) ) { $ target = PREFERRED_RENDERER_TARGET ; } else if ( CLI_SCRIPT ) { $ target = RENDERER_TARGET_CLI ; } else if ( AJAX_SCRIPT ) { $ target = RENDERER_... | Returns suffix of renderer class expected for given target . |
26,683 | protected function standard_renderer_classnames ( $ component , $ subtype = null ) { global $ CFG ; $ classnames = array ( ) ; list ( $ plugin , $ type ) = core_component :: normalize_component ( $ component ) ; if ( $ type === null ) { $ component = $ plugin ; } else { $ component = $ plugin . '_' . $ type ; } if ( $ ... | For a given module name return the possible class names that defines the renderer interface for that module . |
26,684 | public function get_remote_subscribers ( ) { global $ DB ; if ( is_null ( $ this -> cachesubscribers ) ) { $ sql = "SELECT DISTINCT h.id, h.name AS hostname, h.wwwroot AS hosturl, a.display_name AS appname FROM {mnet_host} h JOIN {mnet_host2service} hs... | Returns a list of remote servers that can enrol their users into our courses |
26,685 | public function get_remote_publishers ( ) { global $ DB ; if ( is_null ( $ this -> cachepublishers ) ) { $ sql = "SELECT DISTINCT h.id, h.name AS hostname, h.wwwroot AS hosturl, a.display_name AS appname FROM {mnet_host} h JOIN {mnet_host2service} hs O... | Returns a list of remote servers that offer their courses for our users |
26,686 | public function req_enrol_user ( stdclass $ user , stdclass $ remotecourse ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/xmlrpc/client.php' ) ; $ peer = new mnet_peer ( ) ; $ peer -> set_id ( $ remotecourse -> hostid ) ; $ request = new mnet_xmlrpc_client ( ) ; $ request -> set_method ( 'enrol/mnet... | Send request to enrol our user to the remote course |
26,687 | public function req_unenrol_user ( stdclass $ user , stdclass $ remotecourse ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/xmlrpc/client.php' ) ; $ peer = new mnet_peer ( ) ; $ peer -> set_id ( $ remotecourse -> hostid ) ; $ request = new mnet_xmlrpc_client ( ) ; $ request -> set_method ( 'enrol/mn... | Send request to unenrol our user from the remote course |
26,688 | public function find_users ( $ search ) { global $ CFG , $ DB ; $ systemcontext = context_system :: instance ( ) ; $ userids = get_users_by_capability ( $ systemcontext , 'moodle/site:mnetlogintoremote' , 'u.id' ) ; if ( empty ( $ userids ) ) { return array ( ) ; } list ( $ usql , $ uparams ) = $ DB -> get_in_or_equal ... | Find our users who could be enrolled into the remote course |
26,689 | public function getErrorName ( $ int ) { if ( ! $ this -> _loaded ) { $ this -> load ( ) ; } if ( ! isset ( $ this -> errorNames [ $ int ] ) ) { return "[Error: $int]" ; } return $ this -> errorNames [ $ int ] ; } | Retrieves a localised error name . |
26,690 | public function listify ( $ array ) { $ sep = $ this -> getMessage ( 'Item separator' ) ; $ sep_last = $ this -> getMessage ( 'Item separator last' ) ; $ ret = '' ; for ( $ i = 0 , $ c = count ( $ array ) ; $ i < $ c ; $ i ++ ) { if ( $ i == 0 ) { } elseif ( $ i + 1 < $ c ) { $ ret .= $ sep ; } else { $ ret .= $ sep_la... | Converts an array list into a string readable representation |
26,691 | public function formatMessage ( $ key , $ args = array ( ) ) { if ( ! $ this -> _loaded ) { $ this -> load ( ) ; } if ( ! isset ( $ this -> messages [ $ key ] ) ) { return "[$key]" ; } $ raw = $ this -> messages [ $ key ] ; $ subst = array ( ) ; $ generator = false ; foreach ( $ args as $ i => $ value ) { if ( is_objec... | Formats a localised message with passed parameters |
26,692 | public function add_from_sql ( string $ sql , array $ params ) : contextlist { global $ DB ; $ fields = \ context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; if ( $ fieldname = $ this -> guess_id_field_from_sql ( $ sql ) ) { if ( is_numeric ( $ fieldname ) ) { $ wrapper = " SELECT {$fields} ... | Add a set of contexts from SQL . |
26,693 | public function add_user_context ( int $ userid ) : contextlist { $ sql = "SELECT DISTINCT ctx.id FROM {context} ctx WHERE ctx.contextlevel = :contextlevel AND ctx.instanceid = :instanceid" ; return $ this -> add_from_sql ( $ sql , [ 'contextlevel' => CONTEXT_USER , 'i... | Adds the user context for a given user . |
26,694 | public function add_user_contexts ( array $ userids ) : contextlist { global $ DB ; list ( $ useridsql , $ useridparams ) = $ DB -> get_in_or_equal ( $ userids , SQL_PARAMS_NAMED ) ; $ sql = "SELECT DISTINCT ctx.id FROM {context} ctx WHERE ctx.contextlevel = :contextlevel ... | Adds the user contexts for given users . |
26,695 | protected function guess_id_field_from_sql ( string $ sql ) : string { $ recursiveregexp = '/\((([^()]*|(?R))*)\)/' ; $ sql = ( preg_replace ( $ recursiveregexp , '' , $ sql ) ? : $ sql ) ; $ sql = rtrim ( $ sql , ';' ) ; $ words = array_map ( 'trim' , preg_split ( '/\s+/' , $ sql ) ) ; $ words = array_filter ( $ words... | Guess the name of the contextid field from the supplied SQL . |
26,696 | public function delete_reference ( ) { global $ DB ; if ( ! $ this -> is_external_file ( ) ) { throw new coding_exception ( 'An attempt to unlink a non-reference file.' ) ; } $ transaction = $ DB -> start_delegated_transaction ( ) ; $ countlinks = $ DB -> count_records ( 'files' , array ( 'referencefileid' => $ this ->... | Unlink the stored file from the referenced file |
26,697 | public function delete ( ) { global $ DB ; if ( $ this -> is_directory ( ) ) { $ DB -> delete_records ( 'files' , array ( 'id' => $ this -> file_record -> id ) ) ; } else { $ transaction = $ DB -> start_delegated_transaction ( ) ; if ( $ files = $ this -> fs -> get_references_by_storedfile ( $ this ) ) { foreach ( $ fi... | Delete file from files table . |
26,698 | public function copy_content_to_temp ( $ dir = 'files' , $ fileprefix = 'tempup_' ) { $ tempfile = false ; if ( ! $ dir = make_temp_directory ( $ dir ) ) { return false ; } if ( ! $ tempfile = tempnam ( $ dir , $ fileprefix ) ) { return false ; } if ( ! $ this -> copy_content_to ( $ tempfile ) ) { @ unlink ( $ tempfile... | Copy content of file to temporary folder and returns file path |
26,699 | public function is_valid_image ( ) { $ mimetype = $ this -> get_mimetype ( ) ; if ( ! file_mimetype_in_typegroup ( $ mimetype , 'web_image' ) ) { return false ; } if ( ! $ info = $ this -> get_imageinfo ( ) ) { return false ; } if ( $ info [ 'mimetype' ] !== $ mimetype ) { return false ; } return true ; } | Verifies the file is a valid web image - gif png and jpeg only . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.