idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
3,200
public static function safeFileAppend ( $ filepath , $ str , $ opts = array ( ) ) { $ debug = \ bdk \ Debug :: getInstance ( ) ; $ debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ , $ filepath ) ; $ return = false ; if ( substr ( $ str , - 1 , 1 ) != "\n" ) { $ str .= "\n" ; } $ opts = array_merge ( array ( 'm...
Append string to file
3,201
public static function writeDelimFile ( $ filepath = null , $ rows = array ( ) , $ opts = array ( ) ) { $ debug = \ bdk \ Debug :: getInstance ( ) ; $ debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ , $ filepath ) ; $ return = false ; if ( ! is_array ( $ rows ) ) { $ rows = array ( ) ; } $ est_size = 0 ; $ sa...
Write a delimited file
3,202
public static function & factory ( $ key , array $ params = [ ] , $ store = true ) { if ( static :: has ( $ key ) ) { return static :: get ( $ key ) ; } $ namespace = Path :: toNamespace ( $ key ) ; $ reflection = new ReflectionClass ( $ namespace ) ; $ object = $ reflection -> newInstanceArgs ( $ params ) ; if ( $ sto...
Register a file into memory and return an instantiated object .
3,203
public static function set ( $ object , $ key = null ) { if ( ! is_object ( $ object ) ) { throw new InvalidObjectException ( 'The object to register must be instantiated' ) ; } if ( ! $ key ) { $ key = get_class ( $ object ) ; } static :: $ _registered [ $ key ] = $ object ; return $ object ; }
Store an object into registry .
3,204
protected function getFullPathNameWithHash ( $ fileInfo ) { $ path = $ this -> resourceDirFullPath ; $ path .= '/' . $ fileInfo [ 'hash' ] . '.' . $ fileInfo [ 'ordinal' ] . $ this -> extension ; return $ path ; }
Returns the full path with hash of an resource file .
3,205
protected function getInfoResourceFiles ( ) { $ this -> logVerbose ( 'Get resource files info' ) ; $ resource_dir = $ this -> getProject ( ) -> getReference ( $ this -> resourcesFilesetId ) -> getDir ( $ this -> getProject ( ) ) ; foreach ( $ this -> resourceFileNames as $ filename ) { clearstatcache ( ) ; $ path = $ r...
Get info about each file in the fileset .
3,206
protected function getPathInResources ( $ path ) { if ( strncmp ( $ path , $ this -> parentResourceDirFullPath , strlen ( $ this -> parentResourceDirFullPath ) ) != 0 ) { throw new \ BuildException ( sprintf ( "Resource file '%s' is not under resource dir '%s'." , $ path , $ this -> parentResourceDirFullPath ) ) ; } re...
Gets the path name relative to the parent resource directory of a resource file .
3,207
protected function getPathInResourcesWithHash ( $ baseUrl , $ resourcePathName ) { foreach ( $ this -> resourceFilesInfo as $ info ) { if ( $ info [ 'path_name_in_sources' ] === $ baseUrl . '/' . $ resourcePathName . $ this -> extension ) { return $ info [ 'path_name_in_sources_with_hash' ] ; } } return $ resourcePathN...
Returns path name in sources with hash from the resource info based on the path name in sources . If can t find return path name in sources .
3,208
protected function logError ( ) { $ args = func_get_args ( ) ; $ format = array_shift ( $ args ) ; foreach ( $ args as & $ arg ) { if ( ! is_scalar ( $ arg ) ) $ arg = var_export ( $ arg , true ) ; } if ( $ this -> haltOnError ) throw new \ BuildException ( vsprintf ( $ format , $ args ) ) ; if ( sizeof ( $ args ) == 0...
Prints an error message and depending on HaltOnError throws an exception .
3,209
protected function logInfo ( ) { $ args = func_get_args ( ) ; $ format = array_shift ( $ args ) ; foreach ( $ args as & $ arg ) { if ( ! is_scalar ( $ arg ) ) $ arg = var_export ( $ arg , true ) ; } if ( sizeof ( $ args ) == 0 ) { $ this -> log ( $ format , \ Project :: MSG_INFO ) ; } else { $ this -> log ( vsprintf ( ...
Prints an info message .
3,210
protected function logVerbose ( ) { $ args = func_get_args ( ) ; $ format = array_shift ( $ args ) ; foreach ( $ args as & $ arg ) { if ( ! is_scalar ( $ arg ) ) $ arg = var_export ( $ arg , true ) ; } if ( sizeof ( $ args ) == 0 ) { $ this -> log ( $ format , \ Project :: MSG_VERBOSE ) ; } else { $ this -> log ( vspri...
Prints an verbose level message .
3,211
protected function setFilePermissions ( $ destinationFilename , $ referenceFilename ) { clearstatcache ( ) ; $ perms = fileperms ( $ referenceFilename ) ; if ( $ perms === false ) $ this -> logError ( "Unable to get permissions of file '%s'" , $ referenceFilename ) ; $ status = chmod ( $ destinationFilename , $ perms )...
Sets the mode of a file .
3,212
protected function setModificationTime ( $ destinationFilename , $ newMtime ) { $ status = touch ( $ destinationFilename , $ newMtime ) ; if ( $ status === false ) { $ this -> logError ( "Unable to set mtime of file '%s'" , $ destinationFilename ) ; } }
Copy the mtime form the source file to the destination file .
3,213
protected function store ( $ resource , $ fullPathName , $ parts , $ getInfoBy ) { if ( $ fullPathName !== null ) $ this -> logInfo ( "Minimizing '%s'" , $ fullPathName ) ; $ content_opt = $ this -> minimizeResource ( $ resource , $ fullPathName ) ; $ file_info = [ ] ; $ file_info [ 'hash' ] = md5 ( $ content_opt ) ; $...
Minimize resource create hash based on optimized content . Add resource info into array .
3,214
protected function match ( $ operator , $ pattern , $ value ) { $ value = strtolower ( $ value ) ; $ pattern = strtolower ( $ pattern ) ; switch ( $ operator ) { case '=' : return $ value === $ pattern ; case '!=' : return $ value !== $ pattern ; case '^=' : return preg_match ( '/^' . preg_quote ( $ pattern , '/' ) . '...
Attempts to match the given arguments with the given operator .
3,215
static public function toCollections ( $ object ) { if ( $ object === null ) { return null ; } if ( ! is_array ( $ object ) ) { if ( is_object ( $ object ) ) { foreach ( $ object as $ key => $ value ) { $ object -> $ key = self :: toCollections ( $ value ) ; } } return $ object ; } if ( empty ( $ object ) ) { return ne...
Traverses public attributes of objects and arrays and converts all arrays to Lists and Maps
3,216
public function filter ( $ matcher ) { $ filtered = array ( ) ; foreach ( $ this as $ key => $ element ) { if ( call_user_func ( $ matcher , $ element , $ key ) ) { $ filtered [ $ key ] = $ element ; } } return new static ( $ filtered ) ; }
Filters all elements out that don t match the given matcher .
3,217
public function getExtension ( ) { $ basename = $ this -> getBasename ( ) ; if ( false !== $ pos = strrpos ( $ basename , '.' ) ) { $ ext = substr ( $ basename , $ pos + 1 ) ; } else { $ ext = '' ; } return $ ext ; }
Get filename extension
3,218
public function getReadHandler ( ) { if ( null === $ this -> stream ) { $ this -> stream = fopen ( $ this -> uri , 'r' ) ; } return $ this -> stream ; }
Get a handler resource for reading
3,219
public function getContents ( ) { if ( self :: SCHEME_RESOURCE === $ this -> getScheme ( ) ) { $ contents = '' ; while ( $ data = fread ( $ this -> stream , 2048 ) ) { $ contents .= $ data ; } } else { $ contents = file_get_contents ( $ this -> uri ) ; } return $ contents ; }
Get file contents as binary string
3,220
public function profiler ( $ request , $ response ) { $ this -> _stopTime ( ) ; if ( $ this -> _enabled == true ) { $ dataProfiler = [ ] ; $ dataProfiler [ 'time' ] = round ( $ this -> _time , 2 ) ; $ dataProfiler [ 'timeUser' ] = $ this -> _timeUser ; $ dataProfiler [ 'controller' ] = get_included_files ( ) ; $ dataPr...
at the end put data in cache
3,221
public function addTemplate ( $ name , $ type = self :: TEMPLATE_START , $ file ) { if ( $ this -> _enabled == true ) { switch ( $ type ) { case self :: TEMPLATE_START : $ this -> _template [ $ file ] [ 'name' ] = $ name ; $ this -> _template [ $ file ] [ 'time' ] = microtime ( true ) ; break ; case self :: TEMPLATE_EN...
add a template
3,222
public function addSql ( $ name , $ type = self :: SQL_START , $ value = '' ) { if ( $ this -> _enabled == true ) { switch ( $ type ) { case self :: SQL_START : if ( isset ( $ this -> _sql [ $ name ] ) ) { $ this -> _lastSql = $ name ; } else { $ this -> _lastSql = $ name . rand ( 0 , 10 ) ; } $ this -> _sql [ $ this -...
add a sql query
3,223
public function addTime ( $ name , $ type = self :: USER_START ) { if ( $ this -> _enabled == true ) { switch ( $ type ) { case self :: USER_START : $ this -> _timeUser [ $ name ] = 0 ; $ this -> _timeUser [ $ name ] = microtime ( true ) ; break ; case self :: USER_END : $ this -> _timeUser [ $ name ] = round ( ( micro...
add time to timer
3,224
public function setCustomSSLValidation ( $ sslCustomCA = false , $ sslCustomCN = false ) { $ this -> _sslCustomCA = $ sslCustomCA ; $ this -> _sslCustomCN = $ sslCustomCN ; }
Sets custom CA and Common Name for SSL certificate validation for cases when system validation fails .
3,225
public function setDebug ( $ debugMode ) { $ this -> _debug = $ debugMode ; if ( isset ( $ this -> _connectionSwitcher ) ) { $ this -> _connectionSwitcher -> setDebug ( $ debugMode ) ; } }
Sets the debugging mode
3,226
private function _renderRequest ( CPS_Request & $ request ) { $ envelopeFields = array ( 'storage' => $ this -> _storageName , 'user' => $ this -> _username , 'password' => $ this -> _password , 'command' => $ request -> getCommand ( ) , ) ; if ( count ( $ this -> _customEnvelopeParams ) > 0 ) { foreach ( $ this -> _cu...
Renders the request as XML
3,227
function getLastRequestQuery ( $ stripEnvelope = false ) { $ html = $ this -> _lastRequestQuery ; if ( php_sapi_name ( ) == 'cli' ) { if ( ! $ this -> _debug ) { $ html = preg_replace ( array ( "<\<cps:user\>(.*)\<\/cps:user\>>" , "<\<cps:password\>(.*)\<\/cps:password\>>" ) , array ( '<cps:user>CPS_USER</cps:user>' , ...
returns raw query XML from the last request
3,228
private function _parseConnectionString ( $ string ) { $ res = array ( ) ; if ( ( $ string == '' ) || ( $ string == 'unix://' ) ) { $ res [ 'type' ] = 'socket' ; $ res [ 'host' ] = 'unix:///usr/local/cps2/storages/' . str_replace ( '/' , '_' , $ this -> _storageName ) . '/storage.sock' ; $ res [ 'port' ] = 0 ; } else i...
returns an array with parsed connection string data
3,229
public function newRequest ( CPS_Request & $ request ) { if ( ! array_search ( strtolower ( $ request -> getCommand ( ) ) , $ this -> _non_retry_cmds ) ) { $ this -> _retryRequests = true ; } else { $ this -> _retryRequests = false ; } if ( $ this -> _numUsed == count ( $ this -> _connectionStrings ) ) { $ this -> _use...
This is called by CPS_Connection whenever there is a new request to be sent . This method should not be used directly .
3,230
private function logFailure ( ) { if ( $ this -> _debug ) { printf ( "[LoadBalancer] Failed for %s<br />\n" , $ this -> _connectionStrings [ $ this -> _lastReturnedIndex ] . ( isset ( $ this -> _storageNames [ $ this -> _lastReturnedIndex ] ) ? '|' . $ this -> _storageNames [ $ this -> _lastReturnedIndex ] : '' ) ) ; }...
This function is called whenever there was a sending failure - an error received or an exception raised
3,231
public function logSuccess ( ) { $ this -> _lastSuccess = true ; if ( $ this -> _debug ) { printf ( "[LoadBalancer] Success for %s<br />\n" , $ this -> _connectionStrings [ $ this -> _lastReturnedIndex ] . ( isset ( $ this -> _storageNames [ $ this -> _lastReturnedIndex ] ) ? '|' . $ this -> _storageNames [ $ this -> _...
This function is called whenever there was a sending success - no error received and no exception raised
3,232
public function shouldRetry ( & $ responseString , $ exception , $ transaction_id ) { if ( $ transaction_id ) return false ; if ( ! $ this -> _retryRequests ) return false ; if ( ! is_null ( $ exception ) ) { $ this -> logFailure ( ) ; if ( $ this -> _numUsed == count ( $ this -> _connectionStrings ) ) { return false ;...
This function should return whether a request should be retried depending on response
3,233
public static function _parse_conditions ( $ rights ) { if ( is_array ( $ rights ) ) { return $ rights ; } if ( ! is_string ( $ rights ) or strpos ( $ rights , '.' ) === false ) { throw new \ InvalidArgumentException ( 'Given rights where not formatted proppery. Formatting should be like area.right or area.[right, othe...
Parses a conditions string into it s array equivalent
3,234
protected function populateState ( $ ordering = 'a.lft' , $ direction = 'asc' ) { $ app = JFactory :: getApplication ( ) ; $ forcedLanguage = $ app -> input -> get ( 'forcedLanguage' , '' , 'cmd' ) ; if ( $ layout = $ app -> input -> get ( 'layout' ) ) { $ this -> context .= '.' . $ layout ; } if ( $ forcedLanguage ) {...
Method to auto - populate the model state .
3,235
protected function getStoreId ( $ id = '' ) { $ id .= ':' . $ this -> getState ( 'filter.extension' ) ; $ id .= ':' . $ this -> getState ( 'filter.search' ) ; $ id .= ':' . $ this -> getState ( 'filter.published' ) ; $ id .= ':' . $ this -> getState ( 'filter.access' ) ; $ id .= ':' . $ this -> getState ( 'filter.langu...
Method to get a store id based on model configuration state .
3,236
public function getItems ( ) { $ items = parent :: getItems ( ) ; if ( $ items != false ) { $ extension = $ this -> getState ( 'filter.extension' ) ; $ this -> countItems ( $ items , $ extension ) ; } return $ items ; }
Method to get an array of data items .
3,237
public function countItems ( & $ items , $ extension ) { $ parts = explode ( '.' , $ extension ) ; $ component = $ parts [ 0 ] ; $ section = null ; if ( count ( $ parts ) > 1 ) { $ section = $ parts [ 1 ] ; } $ eName = str_replace ( 'com_' , '' , $ component ) ; $ file = JPath :: clean ( JPATH_ADMINISTRATOR . '/compone...
Method to load the countItems method from the extensions
3,238
public function each ( callable $ callback ) { foreach ( $ this -> all ( ) as $ key => $ value ) { $ callback ( $ key , $ value ) ; } return $ this ; }
Walk thru the elements of the array and apply a function to each
3,239
public function reduce ( callable $ callback , $ initial = null ) : self { return new static ( ( array ) array_reduce ( $ this -> all ( ) , $ callback , $ initial ) ) ; }
Iteratively reduce the array to a single value
3,240
public function reverse ( callable $ callback , bool $ keep_keys = false ) : self { return new static ( array_reverse ( $ this -> all ( ) , $ keep_keys ) ) ; }
Return an array with elements in reverse order
3,241
public function getItemsAction ( Meeting $ meeting ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ items = $ meeting -> getItems ( ) ; $ view = $ this -> view ( $ items , Response :: HTTP_OK ) ; return $ this -> handleView ( $ view ) ; }
Gets the list of all Items for a specific Meeting .
3,242
public function getItemAction ( Item $ item ) { $ view = $ this -> view ( $ item , Response :: HTTP_OK ) ; return $ this -> handleView ( $ view ) ; }
Gets a specific Item .
3,243
static public function endWith ( $ haystack , $ needle ) { if ( substr ( $ haystack , - strlen ( $ needle ) ) === ( string ) $ needle ) { return true ; } return false ; }
end with string
3,244
protected function _setExpiry ( $ expiry ) { if ( is_object ( $ expiry ) && in_array ( get_class ( $ expiry ) , [ Date :: class , FrozenDate :: class , FrozenTime :: class , Time :: class ] ) ) { return $ expiry ; } return new Time ( $ expiry ) ; }
set mutators for expiry property
3,245
protected function _setToken ( $ token ) { if ( ! $ token ) { return $ token ; } $ token = is_string ( $ token ) ? $ token : serialize ( $ token ) ; return substr ( Security :: hash ( $ token , 'sha1' , Configure :: read ( 'Tokens.tokenSalt' ) ) , 0 , 25 ) ; }
set mutators for token property
3,246
public function orderBy ( $ column , $ how = 'ASC' ) { if ( ! array_key_exists ( 'order_by' , $ this -> query ) ) { $ this -> query [ 'order_by' ] = array ( ) ; } if ( is_array ( $ column ) ) { foreach ( $ column as $ col => $ how ) { $ this -> orderBy ( $ col , $ how ) ; } } else { $ this -> query [ 'order_by' ] [ ] =...
Orders the query rows .
3,247
public function where ( $ column , $ value = null ) { if ( ! isset ( $ this -> query [ 'where' ] ) ) { $ this -> query [ 'where' ] = array ( ) ; } if ( $ this -> mergeNextWhere and count ( $ this -> query [ 'where' ] ) > 0 ) { $ this -> mergeNextWhere = false ; return $ this -> _and ( $ column , $ value ) ; } if ( is_a...
Easily add a table = something to the query .
3,248
public function _and ( $ column , $ value = null ) { if ( ! is_array ( $ column ) ) { $ column = array ( $ column => $ value ) ; } $ this -> query [ 'where' ] [ count ( $ this -> query [ 'where' ] ) - 1 ] = array_merge ( $ this -> query [ 'where' ] [ count ( $ this -> query [ 'where' ] ) - 1 ] , $ column ) ; return $ t...
Adds a filter to the last condition group .
3,249
public function join ( $ table , $ on , array $ columns = array ( ) ) { if ( ! array_key_exists ( 'joins' , $ this -> query ) ) { $ this -> query [ 'joins' ] = array ( ) ; } $ this -> query [ 'select' ] = array_merge ( $ this -> query [ 'select' ] , $ columns ) ; $ this -> query [ 'joins' ] [ ] = array ( $ table , $ on...
Join another table .
3,250
public function exec ( ) { $ result = $ this -> connection ( ) -> prepare ( $ this -> assemble ( ) ) ; foreach ( $ this -> valuesToBind as $ key => $ value ) { $ result -> bindValue ( ":{$key}" , $ value ) ; } return $ result -> model ( $ this -> model ) -> exec ( ) ; }
Executes the query and return the statement .
3,251
public function assemble ( ) { $ queryString = array ( ) ; $ queryString [ ] = $ this -> query [ 'type' ] ; if ( $ this -> query [ 'type' ] == "SELECT" or $ this -> query [ 'type' ] == "SELECT DISTINCT" ) { $ queryString [ ] = $ this -> buildSelectColumns ( ) ; $ queryString [ ] = "FROM `{$this->query['table']}`" ; if ...
Private method used to compile the query into a string .
3,252
private function buildSelectColumns ( ) { $ columns = array ( ) ; foreach ( $ this -> query [ 'select' ] as $ column => $ as ) { if ( is_numeric ( $ column ) ) { $ columns [ ] = $ this -> columnName ( $ as ) ; } else { $ columns [ ] = $ this -> columnName ( $ column ) . " AS `{$as}`" ; } } return implode ( ', ' , $ col...
Builds the columns for the select queries .
3,253
private function columnName ( $ column ) { if ( $ column == '*' ) { return "`{$this->query['table']}`.*" ; } if ( strpos ( $ column , '.' ) === false ) { $ column = $ this -> query [ 'table' ] . ".{$column}" ; } if ( strpos ( $ column , '(' ) === false ) { return str_replace ( array ( '.' ) , array ( '`.`' ) , "`{$colu...
Makes the column name safe for queries .
3,254
private function buildWhere ( ) { $ query = array ( ) ; if ( isset ( $ this -> query [ 'where' ] ) and count ( $ this -> query [ 'where' ] ) ) { foreach ( $ this -> query [ 'where' ] as $ group => $ conditions ) { $ group = array ( ) ; foreach ( $ conditions as $ condition => $ value ) { $ cond = explode ( " " , $ cond...
Compiles the where conditions .
3,255
private function buildJoins ( ) { $ joins = array ( ) ; foreach ( $ this -> query [ 'joins' ] as $ join ) { if ( is_array ( $ join [ 0 ] ) ) { $ joins [ ] = "LEFT JOIN `{$join[0][0]}` `{$join[0][1]}` on {$join[1]}" ; } else { $ joins [ ] = "LEFT JOIN `{$join[0]}` on {$join[1]}" ; } } return implode ( " " , $ joins ) ; ...
Compiles the joins .
3,256
private function processValue ( $ value ) { if ( $ value === "NOW()" ) { return $ this -> connection ( ) -> quote ( gmdate ( "Y-m-d H:i:s" ) ) ; } elseif ( $ value === "NULL" ) { return 'NULL' ; } elseif ( is_array ( $ value ) ) { return $ this -> connection ( ) -> quote ( json_encode ( $ value ) ) ; } else { return $ ...
Processes the value .
3,257
public function format ( ) { if ( $ this -> format === null ) { if ( null !== ( $ format = $ this -> parameters -> getParam ( 'format' ) ) ) { $ this -> format = $ format ; } else { $ headers = getallheaders ( ) ; if ( isset ( $ headers [ 'Accept' ] ) ) { $ acceptHeader = $ headers [ 'Accept' ] ; $ negotiator = new For...
Looks for the best format that fits the request . If format is not specified in the request parameters FormatNegotiator is used to determine the best format . If everything fails html is assumed .
3,258
public function uploadedFiles ( ) { if ( ! $ this -> files ) { $ this -> files = new UploadedFiles ( $ _FILES ) ; } return $ this -> files -> files ( ) ; }
Get uploaded files .
3,259
public function render ( $ template , array $ vars = [ ] , array $ blocks = [ ] ) { $ directory = rtrim ( $ this -> directory , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; $ file = $ directory . trim ( $ template , DIRECTORY_SEPARATOR ) . $ this -> suffix ; $ vars += $ this -> vars ; $ sandbox = new Template ( $ this...
Generate content from template compilation
3,260
public static function make ( $ template , array $ vars = [ ] , array $ blocks = [ ] ) { if ( ! static :: $ instance ) { static :: $ instance = new static ; } return static :: $ instance -> render ( $ template , $ vars , $ blocks ) ; }
Generate content from static template compilation
3,261
public function getSex ( ) { $ result = null ; if ( isset ( $ this -> userInfo [ 'sex' ] ) ) { $ result = $ this -> userInfo [ 'sex' ] == 1 ? 'female' : 'male' ; } return $ result ; }
Get user sex or null if it is not set
3,262
public static function getInstance ( $ p_file ) { if ( self :: $ instance === null ) { self :: $ instance = new static ( $ p_file ) ; } return self :: $ instance ; }
Retourne une instance
3,263
public function addBuilds ( BuildIterator $ builds ) { foreach ( $ builds as $ build ) { $ this -> builds -> add ( $ build ) ; } }
Adds a number of builds to the queue .
3,264
public function getNextBuildTime ( ) { $ nextBuildTime = null ; $ build = null ; while ( $ this -> builds -> valid ( ) ) { $ build = $ this -> builds -> current ( ) ; if ( $ build -> getNextBuildTime ( ) <= $ nextBuildTime || $ nextBuildTime === null ) { if ( $ build -> getStatus ( ) != BuildInterface :: STOPPED ) { $ ...
Returns the next build time of all the builds scheduled in this queue .
3,265
public function sortQueue ( $ a , $ b ) { $ buildTimeA = $ a -> getNextBuildTime ( ) ; $ buildTimeB = $ b -> getNextBuildTime ( ) ; if ( $ buildTimeA == $ buildTimeB ) { return 0 ; } return $ buildTimeA < $ buildTimeB ? - 1 : 1 ; }
Sorts the builds in the queue by buildtime .
3,266
public function getNextBuild ( ) { usort ( $ this -> queue , array ( $ this , 'sortQueue' ) ) ; if ( isset ( $ this -> queue [ 0 ] ) ) { if ( $ this -> queue [ 0 ] -> getNextBuildTime ( ) <= time ( ) ) { $ build = array_shift ( $ this -> queue ) ; $ build -> dequeue ( ) ; return $ build ; } } return ; }
Removes the next scheduled build from the queue and returns it .
3,267
public function isPost ( $ redirectUrl = null ) { if ( $ this -> getRequest ( ) -> isPost ) { return true ; } if ( is_null ( $ redirectUrl ) ) { return false ; } return $ this -> redirect ( $ redirectUrl ) -> send ( ) ; }
Checks if the current request is a POST and handles redirection
3,268
function getBaseUrl ( ) { $ filename = $ this -> getServer ( ) -> get ( 'SCRIPT_FILENAME' , '' ) ; $ scriptName = $ this -> getServer ( ) -> get ( 'SCRIPT_NAME' ) ; $ phpSelf = $ this -> getServer ( ) -> get ( 'PHP_SELF' ) ; $ origScriptName = $ this -> getServer ( ) -> get ( 'ORIG_SCRIPT_NAME' , false ) ; if ( $ scrip...
Detect Base Url
3,269
function getBasePath ( ) { $ filename = basename ( $ this -> getServer ( ) -> get ( 'SCRIPT_FILENAME' , '' ) ) ; $ baseUrl = $ this -> getBaseUrl ( ) ; if ( $ baseUrl === '' ) return '' ; if ( basename ( $ baseUrl ) === $ filename ) return str_replace ( '\\' , '/' , dirname ( $ baseUrl ) ) ; return rtrim ( $ baseUrl , ...
Detect Base Path
3,270
public function getEvent ( $ id ) { if ( ! array_key_exists ( $ id , $ this -> identifiers ) ) { return false ; } return $ this -> identifiers [ $ id ] ; }
Retrieve event .
3,271
protected function addStatusMessage ( $ type , $ messages ) { if ( is_array ( $ messages ) ) { foreach ( $ messages as $ message ) { $ _SESSION [ 'messages' ] [ 'status' ] [ $ type ] [ ] = $ message ; } } else { $ _SESSION [ 'messages' ] [ 'status' ] [ $ type ] [ ] = $ messages ; } }
Adds one or more status messages to the response data . Since this response causes a redirection the data is stored in the session .
3,272
public function parse ( Url $ url ) : ? array { $ path = $ url -> path ( ) ; $ pattern = $ this -> buildRoutePattern ( ) ; if ( preg_match ( $ pattern , $ path , $ matches ) === 1 ) { $ variables = [ ] ; $ length = sizeof ( $ matches ) ; for ( $ i = 1 ; $ i < $ length ; $ i ++ ) { $ variables [ $ this -> parameter [ $ ...
Trys to extract all route variables of a given Url . When the route doesen match the Url null will be returned .
3,273
public function match ( $ request_uri , $ request_method , $ rules = array ( ) ) { $ this -> arguments = array ( ) ; if ( $ this -> method != $ request_method ) return false ; if ( $ this -> action == $ request_uri ) return true ; if ( ( $ strpos = strpos ( $ this -> action , '$' ) ) !== false ) { return $ this -> matc...
verifica se l uri richiesta corrisponde alla seguente rotta
3,274
public function call ( $ namespaces = array ( ) ) { foreach ( $ this -> middlewares as $ middleware_class ) { $ middleware = new $ middleware_class ; if ( ! $ middleware -> handle ( ) ) return false ; } return $ this -> call_internal ( $ namespaces ) ; }
ed in seguito chiama la callback
3,275
private function call_internal ( $ namespaces = array ( ) ) { if ( is_callable ( $ this -> callback ) ) { call_user_func_array ( $ this -> callback , $ this -> arguments ) ; return true ; } else if ( is_string ( $ this -> callback ) ) { $ classname = $ this -> callback ; $ action = 'index' ; if ( ( $ strpos = strpos ( ...
esegui la callback
3,276
public function xgetFieldTypes ( $ onlyUsable = false ) { $ fieldTypes = array_keys ( $ this -> _getFields ( ) ) ; if ( $ onlyUsable ) { unset ( $ fieldTypes [ 'root' ] ) ; unset ( $ fieldTypes [ 'referenceroot' ] ) ; unset ( $ fieldTypes [ 'reference' ] ) ; } sort ( $ fieldTypes ) ; return $ fieldTypes ; }
Returns all titles .
3,277
public function setAllData ( $ data ) { array_walk ( $ data , function ( $ value , $ key ) { $ this -> { $ key } = $ value ; } ) ; return $ this ; }
set array of data
3,278
public function delocalizeSegments ( array & $ segments ) { if ( count ( $ segments ) > 0 ) { $ locale = $ segments [ 0 ] ; if ( $ this -> localeHelper -> isValidLocale ( $ locale ) ) { array_shift ( $ segments ) ; } } }
Delocalizes segments in path
3,279
public function performRedirect ( RedirectContainer $ container ) { $ path = $ container -> getRedirectpath ( ) ; $ request = $ container -> getRequest ( ) ; $ request -> flash ( ) ; if ( $ container -> shouldIncludeQuery ( ) ) { $ path .= $ this -> getQueryStringFromRequest ( $ request ) ; } if ( $ container -> should...
Redirects to path with or without querystring
3,280
public function getUri ( $ data = null ) { if ( isset ( $ data [ 'uriData' ] ) ) { $ this -> uri = str_replace ( '{params}' , implode ( '/' , $ data [ 'uriData' ] ) , $ this -> uri ) ; } return $ this -> uri ; }
get the endpoint uri .
3,281
public function getTransformer ( $ type = 'response' ) { return isset ( $ this -> transformers [ $ type ] ) ? $ this -> transformers [ $ type ] : null ; }
Get the endpoint transformer .
3,282
public static function create ( $ engine , $ args = null ) { $ engine = strtolower ( $ engine ) ; if ( self :: validEngine ( $ engine ) ) { return ( isset ( $ args ) ) ? self :: createWithArgs ( $ engine , $ args ) : self :: createWithArgs ( $ engine , array ( ) ) ; } throw new \ Franzip \ SerpFetcher \ Exceptions \ Un...
Return a SerpFetcher implementation for a given search engine .
3,283
private static function createWithArgs ( $ engine , $ args ) { $ engineName = ucfirst ( $ engine ) ; $ className = self :: FETCHER_CLASS_PREFIX . $ engineName . self :: FETCHER_CLASS_SUFFIX ; return call_user_func_array ( array ( new \ ReflectionClass ( $ className ) , 'newInstance' ) , $ args ) ; }
Use reflection to instantiate the right Fetcher at runtime .
3,284
public function add ( $ item , & $ success = null ) { $ result = $ this -> fire ( 'before-add' , $ item ) ; if ( ! $ result -> isPropagationStopped ( ) ) { $ this -> items [ ] = $ this -> decorate ( $ item ) ; $ this -> len ++ ; $ this -> fire ( 'add' , $ item ) ; $ success = true ; } else { $ success = false ; } retur...
Adds an item to collection .
3,285
public function contains ( $ item ) { for ( $ i = 0 ; $ i < $ this -> len ; $ i ++ ) { if ( $ this -> compare ( $ item , $ this -> items [ $ i ] ) === 0 ) { return true ; } } return false ; }
Returns TRUE if this collection contains an item and FALSE otherwise
3,286
public function filter ( $ callback ) { $ result = [ ] ; if ( is_callable ( $ callback ) ) { for ( $ i = 0 ; $ i < $ this -> len ; $ i ++ ) { if ( call_user_func ( $ callback , $ this -> items [ $ i ] , $ i , $ this ) ) { $ result [ ] = & $ this -> items [ $ i ] ; } } } $ myName = get_class ( ) ; return new $ myName ( ...
Returns another collection of the same type with items which are passing a filter test .
3,287
public function sort ( $ callback = null , $ ascending = true ) { if ( null !== $ callback && ! is_callable ( $ callback ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $callback: Expected callable( any, any ): int | null' ) ; } $ result = [ ] ; for ( $ i = 0 ; $ i < $ this -> len ; $ i ++ ) { $ result [ ] ...
Returns a sorted collection based on a user - defined function
3,288
public function unique ( $ callback = null ) { $ result = [ ] ; if ( $ callback === null ) { $ n = 0 ; for ( $ i = 0 ; $ i < $ this -> len ; $ i ++ ) { $ exists = false ; for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ this -> compare ( $ result [ $ j ] , $ this -> items [ $ i ] ) === 0 ) { $ exists = true ; break ; } } ...
Returns a collection with unique items .
3,289
private static function defaultCompareWrapper ( $ a , $ b ) { if ( $ a === $ b ) { return 0 ; } else { if ( is_string ( $ a ) ) { return strcmp ( $ a , $ b . '' ) ; } else if ( is_int ( $ a ) || is_float ( $ b ) ) { return ( float ) $ a - $ b ; } else return - 1 ; } }
A default compare function used by this generic collection
3,290
public function matchRequest ( \ TYPO3 \ Flow \ Mvc \ RequestInterface $ request ) { $ httpRequest = $ request -> getHttpRequest ( ) ; if ( $ httpRequest -> hasHeader ( 'X-Request-Signature' ) ) { $ identifierAndSignature = explode ( ':' , $ httpRequest -> getHeader ( 'X-Request-Signature' ) , 2 ) ; if ( count ( $ iden...
Matches the current request for an unverified signed request .
3,291
public function setTemplatesDirectory ( $ directory ) { $ this -> templatesDirectory = rtrim ( $ directory , DIRECTORY_SEPARATOR ) ; $ this -> engine -> setDirectory ( $ this -> getTemplatesDirectory ( ) ) ; }
Set the base directory that contains view templates
3,292
public function isAcceptable ( RequestInterface $ request ) { $ accept = $ request -> getHeaderLine ( 'Accept' ) ; if ( $ accept && preg_match ( '#^application/([^+\s]+\+)?json#' , $ accept ) ) { return true ; } return false ; }
Is the strategy acceptable for this request?
3,293
public function handleDevelopmentError ( SystemEvent $ systemEvent , $ exception ) { $ details = [ ] ; $ e = $ exception ; while ( $ e ) { $ item = [ 'class' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'trace' ...
Handles an error in development mode .
3,294
public static function v4FromData ( $ data ) { assert ( strlen ( $ data ) == 16 ) ; $ data [ 6 ] = chr ( ord ( $ data [ 6 ] ) & 0x0f | 0x40 ) ; $ data [ 8 ] = chr ( ord ( $ data [ 8 ] ) & 0x3f | 0x80 ) ; return vsprintf ( '%s%s-%s-%s-%s-%s%s%s' , str_split ( bin2hex ( $ data ) , 4 ) ) ; }
Generates a v4 UUID from data .
3,295
public static function forge ( $ config = 'default' , $ connect = true ) { $ ftp = new static ( $ config ) ; $ connect === true and $ ftp -> connect ( ) ; return $ ftp ; }
Returns a new Ftp object . If you do not define the file parameter
3,296
protected function _is_conn ( ) { if ( ! is_resource ( $ this -> _conn_id ) ) { if ( $ this -> _debug == true ) { throw new \ InvalidArgumentException ( 'Invalid connection' ) ; } return false ; } return true ; }
Validates the connection ID
3,297
public function upload ( $ local_path , $ remote_path , $ mode = 'auto' , $ permissions = null ) { if ( ! $ this -> _is_conn ( ) ) { return false ; } if ( ! is_file ( $ local_path ) ) { throw new \ FtpFileAccessException ( 'No source file' ) ; return false ; } if ( $ mode == 'auto' ) { $ ext = pathinfo ( $ local_path ,...
Upload a file to the server
3,298
public function download ( $ remote_path , $ local_path , $ mode = 'auto' ) { if ( ! $ this -> _is_conn ( ) ) { return false ; } if ( $ mode == 'auto' ) { $ ext = pathinfo ( $ remote_path , PATHINFO_BASENAME ) ; $ mode = $ this -> _settype ( $ ext ) ; } $ mode = ( $ mode == 'ascii' ) ? FTP_ASCII : FTP_BINARY ; $ result...
Download a file from a remote server to the local server
3,299
public function mirror ( $ local_path , $ remote_path ) { if ( ! $ this -> _is_conn ( ) ) { return false ; } if ( $ fp = @ opendir ( $ local_path ) ) { if ( ! $ this -> change_dir ( $ remote_path , true ) ) { if ( ! $ this -> mkdir ( $ remote_path ) or ! $ this -> change_dir ( $ remote_path ) ) { return false ; } } whi...
Read a directory and recreate it remotely