idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
25,900 | public function offset ( $ num ) { $ this -> _dirty ( ) ; if ( $ num !== null && ! is_object ( $ num ) ) { $ num = ( int ) $ num ; } $ this -> _parts [ 'offset' ] = $ num ; return $ this ; } | Sets the number of records that should be skipped from the original result set This is commonly used for paginating large results . Accepts an integer or an expression object that evaluates to an integer . |
25,901 | public function union ( $ query , $ overwrite = false ) { if ( $ overwrite ) { $ this -> _parts [ 'union' ] = [ ] ; } $ this -> _parts [ 'union' ] [ ] = [ 'all' => false , 'query' => $ query ] ; $ this -> _dirty ( ) ; return $ this ; } | Adds a complete query to be used in conjunction with an UNION operator with this query . This is used to combine the result set of this query with the one that will be returned by the passed query . You can add as many queries as you required by calling multiple times this method with different queries . |
25,902 | public function unionAll ( $ query , $ overwrite = false ) { if ( $ overwrite ) { $ this -> _parts [ 'union' ] = [ ] ; } $ this -> _parts [ 'union' ] [ ] = [ 'all' => true , 'query' => $ query ] ; $ this -> _dirty ( ) ; return $ this ; } | Adds a complete query to be used in conjunction with the UNION ALL operator with this query . This is used to combine the result set of this query with the one that will be returned by the passed query . You can add as many queries as you required by calling multiple times this method with different queries . |
25,903 | public function into ( $ table ) { $ this -> _dirty ( ) ; $ this -> _type = 'insert' ; $ this -> _parts [ 'insert' ] [ 0 ] = $ table ; return $ this ; } | Set the table name for insert queries . |
25,904 | public function values ( $ data ) { if ( $ this -> _type !== 'insert' ) { throw new Exception ( 'You cannot add values before defining columns to use.' ) ; } if ( empty ( $ this -> _parts [ 'insert' ] ) ) { throw new Exception ( 'You cannot add values before defining columns to use.' ) ; } $ this -> _dirty ( ) ; if ( $... | Set the values for an insert query . |
25,905 | public function set ( $ key , $ value = null , $ types = [ ] ) { if ( empty ( $ this -> _parts [ 'set' ] ) ) { $ this -> _parts [ 'set' ] = $ this -> newExpr ( ) -> setConjunction ( ',' ) ; } if ( $ this -> _parts [ 'set' ] -> isCallable ( $ key ) ) { $ exp = $ this -> newExpr ( ) -> setConjunction ( ',' ) ; $ this -> ... | Set one or many fields to update . |
25,906 | public function newExpr ( $ rawExpression = null ) { $ expression = new QueryExpression ( [ ] , $ this -> getTypeMap ( ) ) ; if ( $ rawExpression !== null ) { $ expression -> add ( $ rawExpression ) ; } return $ expression ; } | Returns a new QueryExpression object . This is a handy function when building complex queries using a fluent interface . You can also override this function in subclasses to use a more specialized QueryExpression class if required . |
25,907 | public function decorateResults ( $ callback , $ overwrite = false ) { if ( $ overwrite ) { $ this -> _resultDecorators = [ ] ; } if ( $ callback !== null ) { $ this -> _resultDecorators [ ] = $ callback ; } return $ this ; } | Registers a callback to be executed for each result that is fetched from the result set the callback function will receive as first parameter an array with the raw data from the database for every row that is fetched and must return the row with any possible modifications . |
25,908 | public function bind ( $ param , $ value , $ type = 'string' ) { $ this -> getValueBinder ( ) -> bind ( $ param , $ value , $ type ) ; return $ this ; } | Associates a query placeholder to a value and a type . |
25,909 | public function valueBinder ( $ binder = null ) { deprecationWarning ( 'Query::valueBinder() is deprecated. Use Query::getValueBinder()/setValueBinder() instead.' ) ; if ( $ binder === null ) { if ( $ this -> _valueBinder === null ) { $ this -> _valueBinder = new ValueBinder ( ) ; } return $ this -> _valueBinder ; } $ ... | Returns the currently used ValueBinder instance . If a value is passed it will be set as the new instance to be used . |
25,910 | public function selectTypeMap ( TypeMap $ typeMap = null ) { deprecationWarning ( 'Query::selectTypeMap() is deprecated. ' . 'Use Query::setSelectTypeMap()/getSelectTypeMap() instead.' ) ; if ( $ typeMap !== null ) { return $ this -> setSelectTypeMap ( $ typeMap ) ; } return $ this -> getSelectTypeMap ( ) ; } | Sets the TypeMap class where the types for each of the fields in the select clause are stored . |
25,911 | protected function _decorateStatement ( $ statement ) { $ typeMap = $ this -> getSelectTypeMap ( ) ; $ driver = $ this -> getConnection ( ) -> getDriver ( ) ; if ( $ this -> typeCastEnabled && $ typeMap -> toArray ( ) ) { $ statement = new CallbackStatement ( $ statement , $ driver , new FieldTypeConverter ( $ typeMap ... | Auxiliary function used to wrap the original statement from the driver with any registered callbacks . |
25,912 | protected function _conjugate ( $ part , $ append , $ conjunction , $ types ) { $ expression = $ this -> _parts [ $ part ] ? : $ this -> newExpr ( ) ; if ( empty ( $ append ) ) { $ this -> _parts [ $ part ] = $ expression ; return ; } if ( $ expression -> isCallable ( $ append ) ) { $ append = $ append ( $ this -> newE... | Helper function used to build conditions by composing QueryExpression objects . |
25,913 | protected function _dirty ( ) { $ this -> _dirty = true ; if ( $ this -> _iterator && $ this -> _valueBinder ) { $ this -> getValueBinder ( ) -> reset ( ) ; } } | Marks a query as dirty removing any preprocessed information from in memory caching . |
25,914 | protected function _displayException ( $ exception ) { $ errorName = 'Exception:' ; if ( $ exception instanceof FatalErrorException ) { $ errorName = 'Fatal Error:' ; } if ( $ exception instanceof PHP7ErrorException ) { $ exception = $ exception -> getError ( ) ; } $ message = sprintf ( '<error>%s</error> %s in [%s, li... | Prints an exception to stderr . |
25,915 | protected function _displayError ( $ error , $ debug ) { $ message = sprintf ( '%s in [%s, line %s]' , $ error [ 'description' ] , $ error [ 'file' ] , $ error [ 'line' ] ) ; $ message = sprintf ( "<error>%s Error:</error> %s\n" , $ error [ 'error' ] , $ message ) ; $ this -> _stderr -> write ( $ message ) ; } | Prints an error to stderr . |
25,916 | public function hasSequences ( ) { $ result = $ this -> _driver -> prepare ( 'SELECT 1 FROM sqlite_master WHERE name = "sqlite_sequence"' ) ; $ result -> execute ( ) ; $ this -> _hasSequences = ( bool ) $ result -> rowCount ( ) ; $ result -> closeCursor ( ) ; return $ this -> _hasSequences ; } | Returns whether there is any table in this connection to SQLite containing sequences |
25,917 | public function image ( $ path , array $ options = [ ] ) { $ pathPrefix = Configure :: read ( 'App.imageBaseUrl' ) ; return $ this -> assetUrl ( $ path , $ options + compact ( 'pathPrefix' ) ) ; } | Generates URL for given image file . |
25,918 | public function script ( $ path , array $ options = [ ] ) { $ pathPrefix = Configure :: read ( 'App.jsBaseUrl' ) ; $ ext = '.js' ; return $ this -> assetUrl ( $ path , $ options + compact ( 'pathPrefix' , 'ext' ) ) ; } | Generates URL for given javascript file . |
25,919 | public function assetUrl ( $ path , array $ options = [ ] ) { if ( is_array ( $ path ) ) { return $ this -> build ( $ path , ! empty ( $ options [ 'fullBase' ] ) ) ; } if ( preg_match ( '/^data:[a-z]+\/[a-z]+;/' , $ path ) ) { return h ( $ path ) ; } if ( strpos ( $ path , '://' ) !== false || preg_match ( '/^[a-z]+:/i... | Generates URL for given asset file . |
25,920 | protected function _encodeUrl ( $ url ) { $ path = parse_url ( $ url , PHP_URL_PATH ) ; $ parts = array_map ( 'rawurldecode' , explode ( '/' , $ path ) ) ; $ parts = array_map ( 'rawurlencode' , $ parts ) ; $ encoded = implode ( '/' , $ parts ) ; $ url = h ( str_replace ( $ path , $ encoded , $ url ) ) ; return $ url ;... | Encodes a URL for use in HTML attributes . |
25,921 | public function webroot ( $ file ) { $ request = $ this -> _View -> getRequest ( ) ; $ asset = explode ( '?' , $ file ) ; $ asset [ 1 ] = isset ( $ asset [ 1 ] ) ? '?' . $ asset [ 1 ] : null ; $ webPath = $ request -> getAttribute ( 'webroot' ) . $ asset [ 0 ] ; $ file = $ asset [ 0 ] ; if ( ! empty ( $ this -> _View -... | Checks if a file exists when theme is used if no file is found default location is returned |
25,922 | protected function _format ( $ data , array $ context = [ ] ) { if ( is_string ( $ data ) ) { return $ data ; } $ isObject = is_object ( $ data ) ; if ( $ isObject && $ data instanceof EntityInterface ) { return json_encode ( $ data , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT ) ; } if ( $ isObject && method_exists ( $... | Converts to string the provided data so it can be logged . The context can optionally be used by log engines to interpolate variables or add additional info to the logged message . |
25,923 | protected function getMailer ( $ name , Email $ email = null ) { if ( $ email === null ) { $ email = new Email ( ) ; } $ className = App :: className ( $ name , 'Mailer' , 'Mailer' ) ; if ( empty ( $ className ) ) { throw new MissingMailerException ( compact ( 'name' ) ) ; } return new $ className ( $ email ) ; } | Returns a mailer instance . |
25,924 | protected function _setOptions ( ) { $ this -> _Memcached -> setOption ( Memcached :: OPT_LIBKETAMA_COMPATIBLE , true ) ; $ serializer = strtolower ( $ this -> _config [ 'serialize' ] ) ; if ( ! isset ( $ this -> _serializers [ $ serializer ] ) ) { throw new InvalidArgumentException ( sprintf ( '%s is not a valid seria... | Settings the memcached instance |
25,925 | public function write ( $ key , $ value ) { $ duration = $ this -> _config [ 'duration' ] ; if ( $ duration > 30 * DAY ) { $ duration = 0 ; } $ key = $ this -> _key ( $ key ) ; return $ this -> _Memcached -> set ( $ key , $ value , $ duration ) ; } | Write data for key into cache . When using memcached as your cache engine remember that the Memcached pecl extension does not support cache expiry times greater than 30 days in the future . Any duration greater than 30 days will be treated as never expiring . |
25,926 | public function writeMany ( $ data ) { $ cacheData = [ ] ; foreach ( $ data as $ key => $ value ) { $ cacheData [ $ this -> _key ( $ key ) ] = $ value ; } $ success = $ this -> _Memcached -> setMulti ( $ cacheData ) ; $ return = [ ] ; foreach ( array_keys ( $ data ) as $ key ) { $ return [ $ key ] = $ success ; } retur... | Write many cache entries to the cache at once |
25,927 | public function readMany ( $ keys ) { $ cacheKeys = [ ] ; foreach ( $ keys as $ key ) { $ cacheKeys [ ] = $ this -> _key ( $ key ) ; } $ values = $ this -> _Memcached -> getMulti ( $ cacheKeys ) ; $ return = [ ] ; foreach ( $ keys as & $ key ) { $ return [ $ key ] = array_key_exists ( $ this -> _key ( $ key ) , $ value... | Read many keys from the cache at once |
25,928 | public function deleteMany ( $ keys ) { $ cacheKeys = [ ] ; foreach ( $ keys as $ key ) { $ cacheKeys [ ] = $ this -> _key ( $ key ) ; } $ success = $ this -> _Memcached -> deleteMulti ( $ cacheKeys ) ; $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = $ success ; } return $ return ; } | Delete many keys from the cache at once |
25,929 | protected function getShell ( ConsoleIo $ io , CommandCollection $ commands , $ name ) { $ instance = $ commands -> get ( $ name ) ; if ( is_string ( $ instance ) ) { $ instance = $ this -> createShell ( $ instance , $ io ) ; } if ( $ instance instanceof Shell ) { $ instance -> setRootName ( $ this -> root ) ; } if ( $... | Get the shell instance for a given command name |
25,930 | protected function longestCommandName ( $ commands , $ argv ) { for ( $ i = 3 ; $ i > 1 ; $ i -- ) { $ parts = array_slice ( $ argv , 0 , $ i ) ; $ name = implode ( ' ' , $ parts ) ; if ( $ commands -> has ( $ name ) ) { return [ $ name , array_slice ( $ argv , $ i ) ] ; } } $ name = array_shift ( $ argv ) ; return [ $... | Build the longest command name that exists in the collection |
25,931 | protected function resolveName ( $ commands , $ io , $ name ) { if ( ! $ name ) { $ io -> err ( '<error>No command provided. Choose one of the available commands.</error>' , 2 ) ; $ name = 'help' ; } if ( isset ( $ this -> aliases [ $ name ] ) ) { $ name = $ this -> aliases [ $ name ] ; } if ( ! $ commands -> has ( $ n... | Resolve the command name into a name that exists in the collection . |
25,932 | protected function runCommand ( Command $ command , array $ argv , ConsoleIo $ io ) { try { return $ command -> run ( $ argv , $ io ) ; } catch ( StopException $ e ) { return $ e -> getCode ( ) ; } } | Execute a Command class . |
25,933 | protected function runShell ( Shell $ shell , array $ argv ) { try { $ shell -> initialize ( ) ; return $ shell -> runCommand ( $ argv , true ) ; } catch ( StopException $ e ) { return $ e -> getCode ( ) ; } } | Execute a Shell class . |
25,934 | protected function createShell ( $ className , ConsoleIo $ io ) { $ shell = $ this -> factory -> create ( $ className ) ; if ( $ shell instanceof Shell ) { $ shell -> setIo ( $ io ) ; } return $ shell ; } | The wrapper for creating shell instances . |
25,935 | protected function loadRoutes ( ) { $ builder = Router :: createRouteBuilder ( '/' ) ; if ( $ this -> app instanceof HttpApplicationInterface ) { $ this -> app -> routes ( $ builder ) ; } if ( $ this -> app instanceof PluginApplicationInterface ) { $ this -> app -> pluginRoutes ( $ builder ) ; } } | Ensure that the application s routes are loaded . |
25,936 | public function current ( ) { $ callback = $ this -> _callback ; return $ callback ( parent :: current ( ) , $ this -> key ( ) , $ this -> _innerIterator ) ; } | Returns the value returned by the callback after passing the current value in the iteration |
25,937 | public function bind ( $ param , $ value , $ type = 'string' ) { $ this -> _bindings [ $ param ] = compact ( 'value' , 'type' ) + [ 'placeholder' => is_int ( $ param ) ? $ param : substr ( $ param , 1 ) ] ; } | Associates a query placeholder to a value and a type |
25,938 | public function generateManyNamed ( $ values , $ type = 'string' ) { $ placeholders = [ ] ; foreach ( $ values as $ k => $ value ) { $ param = $ this -> placeholder ( 'c' ) ; $ this -> _bindings [ $ param ] = [ 'value' => $ value , 'type' => $ type , 'placeholder' => substr ( $ param , 1 ) , ] ; $ placeholders [ $ k ] ... | Creates unique named placeholders for each of the passed values and binds them with the specified type . |
25,939 | public function attachTo ( $ statement ) { $ bindings = $ this -> bindings ( ) ; if ( empty ( $ bindings ) ) { return ; } foreach ( $ bindings as $ b ) { $ statement -> bindValue ( $ b [ 'placeholder' ] , $ b [ 'value' ] , $ b [ 'type' ] ) ; } } | Binds all the stored values in this object to the passed statement . |
25,940 | public function parse ( $ url , $ method = '' ) { $ params = parent :: parse ( $ url , $ method ) ; if ( ! $ params ) { return false ; } $ params [ 'controller' ] = $ params [ 'plugin' ] ; return $ params ; } | Parses a string URL into an array . If a plugin key is found it will be copied to the controller parameter . |
25,941 | public function match ( array $ url , array $ context = [ ] ) { if ( isset ( $ url [ 'controller' ] , $ url [ 'plugin' ] ) && $ url [ 'plugin' ] !== $ url [ 'controller' ] ) { return false ; } $ this -> defaults [ 'controller' ] = $ url [ 'controller' ] ; $ result = parent :: match ( $ url , $ context ) ; unset ( $ thi... | Reverses route plugin shortcut URLs . If the plugin and controller are not the same the match is an auto fail . |
25,942 | public function getConfig ( $ alias = null ) { if ( $ alias === null ) { return $ this -> _config ; } return isset ( $ this -> _config [ $ alias ] ) ? $ this -> _config [ $ alias ] : [ ] ; } | Returns configuration for an alias or the full configuration array for all aliases . |
25,943 | public function get ( $ alias , array $ options = [ ] ) { if ( isset ( $ this -> _instances [ $ alias ] ) ) { if ( ! empty ( $ options ) && $ this -> _options [ $ alias ] !== $ options ) { throw new RuntimeException ( sprintf ( 'You cannot configure "%s", it already exists in the registry.' , $ alias ) ) ; } return $ t... | Get a table instance from the registry . |
25,944 | protected function _getClassName ( $ alias , array $ options = [ ] ) { if ( empty ( $ options [ 'className' ] ) ) { $ options [ 'className' ] = Inflector :: camelize ( $ alias ) ; } return App :: className ( $ options [ 'className' ] , 'Model/Table' , 'Table' ) ; } | Gets the table class name . |
25,945 | protected function _insertPlaceHolder ( $ matches ) { $ match = $ matches [ 0 ] ; $ envelope = [ '' , '' ] ; if ( isset ( $ matches [ 'url' ] ) ) { $ match = $ matches [ 'url' ] ; $ envelope = [ $ matches [ 'left' ] , $ matches [ 'right' ] ] ; } if ( isset ( $ matches [ 'url_bare' ] ) ) { $ match = $ matches [ 'url_bar... | Saves the placeholder for a string for later use . This gets around double escaping content in URL s . |
25,946 | protected function _linkUrls ( $ text , $ htmlOptions ) { $ replace = [ ] ; foreach ( $ this -> _placeholders as $ hash => $ content ) { $ link = $ url = $ content [ 'content' ] ; $ envelope = $ content [ 'envelope' ] ; if ( ! preg_match ( '#^[a-z]+\://#i' , $ url ) ) { $ url = 'http://' . $ url ; } $ replace [ $ hash ... | Replace placeholders with links . |
25,947 | protected function _linkEmails ( $ text , $ options ) { $ replace = [ ] ; foreach ( $ this -> _placeholders as $ hash => $ content ) { $ url = $ content [ 'content' ] ; $ envelope = $ content [ 'envelope' ] ; $ replace [ $ hash ] = $ envelope [ 0 ] . $ this -> Html -> link ( $ url , 'mailto:' . $ url , $ options ) . $ ... | Links email addresses |
25,948 | public function autoLink ( $ text , array $ options = [ ] ) { $ text = $ this -> autoLinkUrls ( $ text , $ options ) ; return $ this -> autoLinkEmails ( $ text , [ 'escape' => false ] + $ options ) ; } | Convert all links and email addresses to HTML links . |
25,949 | public function i18nFormat ( $ format = null , $ timezone = null , $ locale = null ) { if ( $ format === Time :: UNIX_TIMESTAMP_FORMAT ) { return $ this -> getTimestamp ( ) ; } $ time = $ this ; if ( $ timezone ) { $ time = clone $ this ; $ time = $ time -> timezone ( $ timezone ) ; } $ format = $ format !== null ? $ f... | Returns a formatted string for this time object using the preferred format and language for the specified locale . |
25,950 | public static function parseDateTime ( $ time , $ format = null ) { $ dateFormat = $ format ? : static :: $ _toStringFormat ; $ timeFormat = $ pattern = null ; if ( is_array ( $ dateFormat ) ) { list ( $ newDateFormat , $ timeFormat ) = $ dateFormat ; $ dateFormat = $ newDateFormat ; } else { $ pattern = $ dateFormat ;... | Returns a new Time object after parsing the provided time string based on the passed or configured date time format . This method is locale dependent Any string that is passed to this function will be interpreted as a locale dependent string . |
25,951 | public function listTables ( ) { list ( $ sql , $ params ) = $ this -> _dialect -> listTablesSql ( $ this -> _connection -> config ( ) ) ; $ result = [ ] ; $ statement = $ this -> _connection -> execute ( $ sql , $ params ) ; while ( $ row = $ statement -> fetch ( ) ) { $ result [ ] = $ row [ 0 ] ; } $ statement -> clo... | Get the list of tables available in the current connection . |
25,952 | public function describe ( $ name , array $ options = [ ] ) { $ config = $ this -> _connection -> config ( ) ; if ( strpos ( $ name , '.' ) ) { list ( $ config [ 'schema' ] , $ name ) = explode ( '.' , $ name ) ; } $ table = new TableSchema ( $ name ) ; $ this -> _reflect ( 'Column' , $ name , $ config , $ table ) ; if... | Get the column metadata for a table . |
25,953 | protected function _reflect ( $ stage , $ name , $ config , $ schema ) { $ describeMethod = "describe{$stage}Sql" ; $ convertMethod = "convert{$stage}Description" ; list ( $ sql , $ params ) = $ this -> _dialect -> { $ describeMethod } ( $ name , $ config ) ; if ( empty ( $ sql ) ) { return ; } try { $ statement = $ th... | Helper method for running each step of the reflection process . |
25,954 | public function defaultTypes ( array $ types = null ) { deprecationWarning ( 'TypeMapTrait::defaultTypes() is deprecated. ' . 'Use TypeMapTrait::setDefaultTypes()/getDefaultTypes() instead.' ) ; if ( $ types !== null ) { return $ this -> setDefaultTypes ( $ types ) ; } return $ this -> getDefaultTypes ( ) ; } | Allows setting default types when chaining query |
25,955 | public function __isset ( $ helper ) { if ( isset ( $ this -> _loaded [ $ helper ] ) ) { return true ; } try { $ this -> load ( $ helper ) ; } catch ( Exception \ MissingHelperException $ exception ) { if ( $ this -> _View -> getPlugin ( ) ) { $ this -> load ( $ this -> _View -> getPlugin ( ) . '.' . $ helper ) ; retur... | Tries to lazy load a helper based on its name if it cannot be found in the application folder then it tries looking under the current plugin if any |
25,956 | protected function _create ( $ class , $ alias , $ settings ) { $ instance = new $ class ( $ this -> _View , $ settings ) ; $ enable = isset ( $ settings [ 'enabled' ] ) ? $ settings [ 'enabled' ] : true ; if ( $ enable ) { $ this -> getEventManager ( ) -> on ( $ instance ) ; } return $ instance ; } | Create the helper instance . |
25,957 | protected function _getPaths ( ) { $ defaultPath = APP ; while ( true ) { $ currentPaths = count ( $ this -> _paths ) > 0 ? $ this -> _paths : [ 'None' ] ; $ message = sprintf ( "Current paths: %s\nWhat is the path you would like to extract?\n[Q]uit [D]one" , implode ( ', ' , $ currentPaths ) ) ; $ response = $ this ->... | Method to interact with the User and get path selections . |
25,958 | protected function _addTranslation ( $ domain , $ msgid , $ details = [ ] ) { $ context = isset ( $ details [ 'msgctxt' ] ) ? $ details [ 'msgctxt' ] : '' ; if ( empty ( $ this -> _translations [ $ domain ] [ $ msgid ] [ $ context ] ) ) { $ this -> _translations [ $ domain ] [ $ msgid ] [ $ context ] = [ 'msgid_plural'... | Add a translation to the internal translations property |
25,959 | protected function _extractTokens ( ) { $ progress = $ this -> helper ( 'progress' ) ; $ progress -> init ( [ 'total' => count ( $ this -> _files ) ] ) ; $ isVerbose = $ this -> param ( 'verbose' ) ; $ functions = [ '__' => [ 'singular' ] , '__n' => [ 'singular' , 'plural' ] , '__d' => [ 'domain' , 'singular' ] , '__dn... | Extract tokens out of all files to be processed |
25,960 | protected function _buildFiles ( ) { $ paths = $ this -> _paths ; $ paths [ ] = realpath ( APP ) . DIRECTORY_SEPARATOR ; usort ( $ paths , function ( $ a , $ b ) { return strlen ( $ a ) - strlen ( $ b ) ; } ) ; foreach ( $ this -> _translations as $ domain => $ translations ) { foreach ( $ translations as $ msgid => $ ... | Build the translate template file contents out of obtained strings |
25,961 | protected function _store ( $ domain , $ header , $ sentence ) { if ( ! isset ( $ this -> _storage [ $ domain ] ) ) { $ this -> _storage [ $ domain ] = [ ] ; } if ( ! isset ( $ this -> _storage [ $ domain ] [ $ sentence ] ) ) { $ this -> _storage [ $ domain ] [ $ sentence ] = $ header ; } else { $ this -> _storage [ $ ... | Prepare a file to be stored |
25,962 | protected function _writeFiles ( ) { $ overwriteAll = false ; if ( ! empty ( $ this -> params [ 'overwrite' ] ) ) { $ overwriteAll = true ; } foreach ( $ this -> _storage as $ domain => $ sentences ) { $ output = $ this -> _writeHeader ( ) ; foreach ( $ sentences as $ sentence => $ header ) { $ output .= $ header . $ s... | Write the files that need to be stored |
25,963 | protected function _writeHeader ( ) { $ output = "# LANGUAGE translation of CakePHP Application\n" ; $ output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n" ; $ output .= "#\n" ; $ output .= "#, fuzzy\n" ; $ output .= "msgid \"\"\n" ; $ output .= "msgstr \"\"\n" ; $ output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n... | Build the translation template header |
25,964 | protected function _getStrings ( & $ position , $ target ) { $ strings = [ ] ; $ count = count ( $ strings ) ; while ( $ count < $ target && ( $ this -> _tokens [ $ position ] === ',' || $ this -> _tokens [ $ position ] [ 0 ] == T_CONSTANT_ENCAPSED_STRING || $ this -> _tokens [ $ position ] [ 0 ] == T_LNUMBER ) ) { $ c... | Get the strings from the position forward |
25,965 | protected function _formatString ( $ string ) { $ quote = substr ( $ string , 0 , 1 ) ; $ string = substr ( $ string , 1 , - 1 ) ; if ( $ quote === '"' ) { $ string = stripcslashes ( $ string ) ; } else { $ string = strtr ( $ string , [ "\\'" => "'" , '\\\\' => '\\' ] ) ; } $ string = str_replace ( "\r\n" , "\n" , $ st... | Format a string to be added as a translatable string |
25,966 | protected function _markerError ( $ file , $ line , $ marker , $ count ) { if ( strpos ( $ this -> _file , CAKE_CORE_INCLUDE_PATH ) === false ) { $ this -> _countMarkerError ++ ; } if ( ! $ this -> _markerError ) { return ; } $ this -> err ( sprintf ( "Invalid marker content in %s:%s\n* %s(" , $ file , $ line , $ marke... | Indicate an invalid marker on a processed file |
25,967 | protected function _searchFiles ( ) { $ pattern = false ; if ( ! empty ( $ this -> _exclude ) ) { $ exclude = [ ] ; foreach ( $ this -> _exclude as $ e ) { if ( DIRECTORY_SEPARATOR !== '\\' && $ e [ 0 ] !== DIRECTORY_SEPARATOR ) { $ e = DIRECTORY_SEPARATOR . $ e ; } $ exclude [ ] = preg_quote ( $ e , '/' ) ; } $ patter... | Search files that may contain translatable strings |
25,968 | protected function _isPathUsable ( $ path ) { if ( ! is_dir ( $ path ) ) { mkdir ( $ path , 0770 , true ) ; } return is_dir ( $ path ) && is_writable ( $ path ) ; } | Checks whether or not a given path is usable for writing . |
25,969 | public function format ( $ locale , $ message , array $ vars ) { unset ( $ vars [ '_singular' ] , $ vars [ '_count' ] ) ; return $ this -> _formatMessage ( $ locale , $ message , $ vars ) ; } | Returns a string with all passed variables interpolated into the original message . Variables are interpolated using the MessageFormatter class . |
25,970 | protected function _formatMessage ( $ locale , $ message , $ vars ) { if ( $ message === '' ) { return $ message ; } $ result = MessageFormatter :: formatMessage ( $ locale , $ message , $ vars ) ; if ( $ result === false ) { $ formatter = new MessageFormatter ( $ locale , $ message ) ; if ( ! $ formatter ) { throw new... | Does the actual formatting using the MessageFormatter class |
25,971 | public function log ( $ level , $ message , array $ context = [ ] ) { $ message = $ this -> _format ( $ message , $ context ) ; $ output = date ( 'Y-m-d H:i:s' ) . ' ' . ucfirst ( $ level ) . ': ' . $ message ; return ( bool ) $ this -> _output -> write ( sprintf ( '<%s>%s</%s>' , $ level , $ output , $ level ) ) ; } | Implements writing to console . |
25,972 | public function setName ( $ name ) { if ( $ this -> _targetTable !== null ) { $ alias = $ this -> _targetTable -> getAlias ( ) ; if ( $ alias !== $ name ) { throw new InvalidArgumentException ( 'Association name does not match target table alias.' ) ; } } $ this -> _name = $ name ; return $ this ; } | Sets the name for this association usually the alias assigned to the target associated table |
25,973 | public function name ( $ name = null ) { deprecationWarning ( get_called_class ( ) . '::name() is deprecated. ' . 'Use setName()/getName() instead.' ) ; if ( $ name !== null ) { $ this -> setName ( $ name ) ; } return $ this -> getName ( ) ; } | Sets the name for this association . |
25,974 | public function cascadeCallbacks ( $ cascadeCallbacks = null ) { deprecationWarning ( get_called_class ( ) . '::cascadeCallbacks() is deprecated. ' . 'Use setCascadeCallbacks()/getCascadeCallbacks() instead.' ) ; if ( $ cascadeCallbacks !== null ) { $ this -> setCascadeCallbacks ( $ cascadeCallbacks ) ; } return $ this... | Sets whether or not cascaded deletes should also fire callbacks . If no arguments are passed the current configured value is returned |
25,975 | public function setClassName ( $ className ) { if ( $ this -> _targetTable !== null && get_class ( $ this -> _targetTable ) !== App :: className ( $ className , 'Model/Table' , 'Table' ) ) { throw new InvalidArgumentException ( 'The class name doesn\'t match the target table\'s class name.' ) ; } $ this -> _className =... | Sets the class name of the target table object . |
25,976 | public function source ( Table $ table = null ) { deprecationWarning ( get_called_class ( ) . '::source() is deprecated. ' . 'Use setSource()/getSource() instead.' ) ; if ( $ table === null ) { return $ this -> _sourceTable ; } return $ this -> _sourceTable = $ table ; } | Sets the table instance for the source side of the association . If no arguments are passed the current configured table instance is returned |
25,977 | public function getTarget ( ) { if ( ! $ this -> _targetTable ) { if ( strpos ( $ this -> _className , '.' ) ) { list ( $ plugin ) = pluginSplit ( $ this -> _className , true ) ; $ registryAlias = $ plugin . $ this -> _name ; } else { $ registryAlias = $ this -> _name ; } $ tableLocator = $ this -> getTableLocator ( ) ... | Gets the table instance for the target side of the association . |
25,978 | public function target ( Table $ table = null ) { deprecationWarning ( get_called_class ( ) . '::target() is deprecated. ' . 'Use setTarget()/getTarget() instead.' ) ; if ( $ table !== null ) { $ this -> setTarget ( $ table ) ; } return $ this -> getTarget ( ) ; } | Sets the table instance for the target side of the association . If no arguments are passed the current configured table instance is returned |
25,979 | public function conditions ( $ conditions = null ) { deprecationWarning ( get_called_class ( ) . '::conditions() is deprecated. ' . 'Use setConditions()/getConditions() instead.' ) ; if ( $ conditions !== null ) { $ this -> setConditions ( $ conditions ) ; } return $ this -> getConditions ( ) ; } | Sets a list of conditions to be always included when fetching records from the target association . If no parameters are passed the current list is returned |
25,980 | public function getBindingKey ( ) { if ( $ this -> _bindingKey === null ) { $ this -> _bindingKey = $ this -> isOwningSide ( $ this -> getSource ( ) ) ? $ this -> getSource ( ) -> getPrimaryKey ( ) : $ this -> getTarget ( ) -> getPrimaryKey ( ) ; } return $ this -> _bindingKey ; } | Gets the name of the field representing the binding field with the target table . When not manually specified the primary key of the owning side table is used . |
25,981 | public function bindingKey ( $ key = null ) { deprecationWarning ( get_called_class ( ) . '::bindingKey() is deprecated. ' . 'Use setBindingKey()/getBindingKey() instead.' ) ; if ( $ key !== null ) { $ this -> setBindingKey ( $ key ) ; } return $ this -> getBindingKey ( ) ; } | Sets the name of the field representing the binding field with the target table . When not manually specified the primary key of the owning side table is used . |
25,982 | public function foreignKey ( $ key = null ) { deprecationWarning ( get_called_class ( ) . '::foreignKey() is deprecated. ' . 'Use setForeignKey()/getForeignKey() instead.' ) ; if ( $ key !== null ) { $ this -> setForeignKey ( $ key ) ; } return $ this -> getForeignKey ( ) ; } | Sets the name of the field representing the foreign key to the target table . If no parameters are passed the current field is returned |
25,983 | public function dependent ( $ dependent = null ) { deprecationWarning ( get_called_class ( ) . '::dependent() is deprecated. ' . 'Use setDependent()/getDependent() instead.' ) ; if ( $ dependent !== null ) { $ this -> setDependent ( $ dependent ) ; } return $ this -> getDependent ( ) ; } | Sets whether the records on the target table are dependent on the source table . |
25,984 | public function canBeJoined ( array $ options = [ ] ) { $ strategy = isset ( $ options [ 'strategy' ] ) ? $ options [ 'strategy' ] : $ this -> getStrategy ( ) ; return $ strategy == $ this :: STRATEGY_JOIN ; } | Whether this association can be expressed directly in a query join |
25,985 | public function joinType ( $ type = null ) { deprecationWarning ( get_called_class ( ) . '::joinType() is deprecated. ' . 'Use setJoinType()/getJoinType() instead.' ) ; if ( $ type !== null ) { $ this -> setJoinType ( $ type ) ; } return $ this -> getJoinType ( ) ; } | Sets the type of join to be used when adding the association to a query . If no arguments are passed the currently configured type is returned . |
25,986 | public function getProperty ( ) { if ( ! $ this -> _propertyName ) { $ this -> _propertyName = $ this -> _propertyName ( ) ; if ( in_array ( $ this -> _propertyName , $ this -> _sourceTable -> getSchema ( ) -> columns ( ) ) ) { $ msg = 'Association property name "%s" clashes with field of same name of table "%s".' . ' ... | Gets the property name that should be filled with data from the target table in the source table record . |
25,987 | public function property ( $ name = null ) { deprecationWarning ( get_called_class ( ) . '::property() is deprecated. ' . 'Use setProperty()/getProperty() instead.' ) ; if ( $ name !== null ) { $ this -> setProperty ( $ name ) ; } return $ this -> getProperty ( ) ; } | Sets the property name that should be filled with data from the target table in the source table record . If no arguments are passed the currently configured type is returned . |
25,988 | public function setStrategy ( $ name ) { if ( ! in_array ( $ name , $ this -> _validStrategies ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid strategy "%s" was provided' , $ name ) ) ; } $ this -> _strategy = $ name ; return $ this ; } | Sets the strategy name to be used to fetch associated records . Keep in mind that some association types might not implement but a default strategy rendering any changes to this setting void . |
25,989 | public function strategy ( $ name = null ) { deprecationWarning ( get_called_class ( ) . '::strategy() is deprecated. ' . 'Use setStrategy()/getStrategy() instead.' ) ; if ( $ name !== null ) { $ this -> setStrategy ( $ name ) ; } return $ this -> getStrategy ( ) ; } | Sets the strategy name to be used to fetch associated records . Keep in mind that some association types might not implement but a default strategy rendering any changes to this setting void . If no arguments are passed the currently configured strategy is returned . |
25,990 | public function finder ( $ finder = null ) { deprecationWarning ( get_called_class ( ) . '::finder() is deprecated. ' . 'Use setFinder()/getFinder() instead.' ) ; if ( $ finder !== null ) { $ this -> setFinder ( $ finder ) ; } return $ this -> getFinder ( ) ; } | Sets the default finder to use for fetching rows from the target table . If no parameters are passed it will return the currently configured finder name . |
25,991 | protected function _appendNotMatching ( $ query , $ options ) { $ target = $ this -> _targetTable ; if ( ! empty ( $ options [ 'negateMatch' ] ) ) { $ primaryKey = $ query -> aliasFields ( ( array ) $ target -> getPrimaryKey ( ) , $ this -> _name ) ; $ query -> andWhere ( function ( $ exp ) use ( $ primaryKey ) { array... | Conditionally adds a condition to the passed Query that will make it find records where there is no match with this association . |
25,992 | public function transformRow ( $ row , $ nestKey , $ joined , $ targetProperty = null ) { $ sourceAlias = $ this -> getSource ( ) -> getAlias ( ) ; $ nestKey = $ nestKey ? : $ this -> _name ; $ targetProperty = $ targetProperty ? : $ this -> getProperty ( ) ; if ( isset ( $ row [ $ sourceAlias ] ) ) { $ row [ $ sourceA... | Correctly nests a result row associated values into the correct array keys inside the source results . |
25,993 | public function defaultRowValue ( $ row , $ joined ) { $ sourceAlias = $ this -> getSource ( ) -> getAlias ( ) ; if ( isset ( $ row [ $ sourceAlias ] ) ) { $ row [ $ sourceAlias ] [ $ this -> getProperty ( ) ] = null ; } return $ row ; } | Returns a modified row after appending a property for this association with the default empty value according to whether the association was joined or fetched externally . |
25,994 | public function find ( $ type = null , array $ options = [ ] ) { $ type = $ type ? : $ this -> getFinder ( ) ; list ( $ type , $ opts ) = $ this -> _extractFinder ( $ type ) ; return $ this -> getTarget ( ) -> find ( $ type , $ options + $ opts ) -> where ( $ this -> getConditions ( ) ) ; } | Proxies the finding operation to the target table s find method and modifies the query accordingly based of this association configuration |
25,995 | public function exists ( $ conditions ) { if ( $ this -> _conditions ) { $ conditions = $ this -> find ( 'all' , [ 'conditions' => $ conditions ] ) -> clause ( 'where' ) ; } return $ this -> getTarget ( ) -> exists ( $ conditions ) ; } | Proxies the operation to the target table s exists method after appending the default conditions for this association |
25,996 | public function updateAll ( $ fields , $ conditions ) { $ target = $ this -> getTarget ( ) ; $ expression = $ target -> query ( ) -> where ( $ this -> getConditions ( ) ) -> where ( $ conditions ) -> clause ( 'where' ) ; return $ target -> updateAll ( $ fields , $ expression ) ; } | Proxies the update operation to the target table s updateAll method |
25,997 | public function deleteAll ( $ conditions ) { $ target = $ this -> getTarget ( ) ; $ expression = $ target -> query ( ) -> where ( $ this -> getConditions ( ) ) -> where ( $ conditions ) -> clause ( 'where' ) ; return $ target -> deleteAll ( $ expression ) ; } | Proxies the delete operation to the target table s deleteAll method |
25,998 | public function requiresKeys ( array $ options = [ ] ) { $ strategy = isset ( $ options [ 'strategy' ] ) ? $ options [ 'strategy' ] : $ this -> getStrategy ( ) ; return $ strategy === static :: STRATEGY_SELECT ; } | Returns true if the eager loading process will require a set of the owning table s binding keys in order to use them as a filter in the finder query . |
25,999 | protected function _appendFields ( $ query , $ surrogate , $ options ) { if ( $ query -> getEagerLoader ( ) -> isAutoFieldsEnabled ( ) === false ) { return ; } $ fields = $ surrogate -> clause ( 'select' ) ? : $ options [ 'fields' ] ; $ target = $ this -> _targetTable ; $ autoFields = $ surrogate -> isAutoFieldsEnabled... | Helper function used to conditionally append fields to the select clause of a query from the fields found in another query object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.