idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,100
public function save ( Query $ query , array $ options = [ ] ) { $ type = $ query -> getType ( ) ; if ( $ type === Query :: DELETE ) { return $ this -> _processDelete ( $ query , $ options ) ; } else if ( $ type === Query :: INSERT ) { return $ this -> _processCreate ( $ query , $ options ) ; } else if ( $ type === Que...
Return a count of how many rows were affected by the query .
7,101
public function update ( $ id , $ data , array $ options = [ ] ) { return $ this -> query ( Query :: UPDATE ) -> where ( $ this -> getPrimaryKey ( ) , $ id ) -> save ( $ data , $ options ) ; }
Update a database record based on ID .
7,102
public function updateMany ( $ data , Closure $ conditions , array $ options = [ ] ) { return $ this -> query ( Query :: UPDATE ) -> bindCallback ( $ conditions ) -> save ( $ data , $ options ) ; }
Update multiple records with conditions .
7,103
public function upsert ( $ data , $ id = null , array $ options = [ ] ) { $ pk = $ this -> getPrimaryKey ( ) ; $ update = false ; if ( ! $ id && isset ( $ data [ $ pk ] ) ) { $ id = $ data [ $ pk ] ; } unset ( $ data [ $ pk ] ) ; if ( $ id ) { $ update = $ this -> exists ( $ id ) ; } if ( $ update ) { if ( $ this -> up...
Either update or insert a record by checking for ID and record existence .
7,104
protected function _processCreate ( Query $ query , array $ options = [ ] ) { $ data = $ query -> getData ( ) ; $ options = $ options + [ 'before' => true , 'after' => true ] ; if ( $ options [ 'before' ] ) { foreach ( [ 'db.preSave' , 'db.preCreate' ] as $ event ) { $ event = $ this -> emit ( $ event , [ $ query , nul...
Primary method that handles the processing of insert queries .
7,105
protected function _processDelete ( Query $ query , array $ options = [ ] ) { $ options = $ options + [ 'before' => true , 'after' => true ] ; $ this -> id = $ id = $ this -> findID ( $ query ) ; if ( $ options [ 'before' ] ) { $ event = $ this -> emit ( 'db.preDelete' , [ $ query , $ id ] ) ; $ state = $ event -> getS...
Primary method that handles the processing of delete queries .
7,106
protected function _processUpdate ( Query $ query , array $ options = [ ] ) { $ data = $ query -> getData ( ) ; $ options = $ options + [ 'before' => true , 'after' => true ] ; $ this -> id = $ id = $ this -> findID ( $ query ) ; if ( $ options [ 'before' ] ) { foreach ( [ 'db.preSave' , 'db.preUpdate' ] as $ event ) {...
Primary method that handles the processing of update queries .
7,107
function clearLog ( ) : void { @ unlink ( $ this -> errLogger -> getFile ( ) ) ; @ unlink ( $ this -> logger -> getFile ( ) ) ; @ unlink ( $ this -> errLogger -> getFile ( ) . '.shell' ) ; @ unlink ( $ this -> logger -> getFile ( ) . '.shell' ) ; }
Cleans daemon log
7,108
public function getDefaultBlade ( ) : ? BladeCompiler { $ view = View :: getFacadeRoot ( ) ; if ( isset ( $ view ) ) { return Blade :: getFacadeRoot ( ) ; } return $ view ; }
Get a default blade value if any is available
7,109
public static function add ( $ key , $ path , $ url = null ) { static :: $ paths [ $ key ] = $ path ; if ( ! is_null ( $ url ) ) { static :: $ urls [ $ key ] = $ url ; } }
Adds a new storage directory
7,110
public static function file ( $ file ) { $ params = array_merge ( static :: $ params , array ( 'time' => time ( ) , 'fingerprint' => \ CCSession :: fingerprint ( ) , 'random' => CCStr :: random ( ) , ) ) ; foreach ( $ params as $ param => $ value ) { $ file = str_replace ( ':' . $ param , $ value , $ file ) ; } return ...
Prepares a file with the parameters
7,111
public static function url ( $ file = null , $ key = null ) { if ( is_null ( $ key ) ) { $ key = static :: $ default ; } if ( ! isset ( static :: $ urls [ $ key ] ) ) { throw new CCException ( 'CCStorage - use of undefined public url ' . $ key . '.' ) ; } return CCUrl :: to ( static :: $ urls [ $ key ] . $ file ) ; }
Get the public url to a file if available
7,112
public static function write ( $ file , $ content , $ key = null ) { return CCFile :: write ( static :: path ( $ file , $ key ) , $ content ) ; }
Write a file to the storage
7,113
public function setComment ( $ newComment = NULL ) { if ( $ this -> isFinalized ) { return FALSE ; } $ this -> zipComment = $ newComment ; return TRUE ; }
Set Zip archive comment .
7,114
public function addDirectory ( $ directoryPath , $ timestamp = 0 , $ fileComment = NULL , $ extFileAttr = self :: EXT_FILE_ATTR_DIR ) { if ( $ this -> isFinalized ) { return FALSE ; } $ directoryPath = str_replace ( "\\" , "/" , $ directoryPath ) ; $ directoryPath = rtrim ( $ directoryPath , "/" ) ; if ( strlen ( $ dir...
Add an empty directory entry to the zip archive . Basically this is only used if an empty directory is added .
7,115
public function addStreamData ( $ data ) { if ( $ this -> isFinalized || strlen ( $ this -> streamFilePath ) == 0 ) { return FALSE ; } $ length = fwrite ( $ this -> streamData , $ data , strlen ( $ data ) ) ; if ( $ length != strlen ( $ data ) ) { throw new Exception ( "File IO: Error writing; Length mismatch: Expected...
Add data to the open stream .
7,116
public function closeStream ( ) { if ( $ this -> isFinalized || strlen ( $ this -> streamFilePath ) == 0 ) { return FALSE ; } fflush ( $ this -> streamData ) ; fclose ( $ this -> streamData ) ; $ this -> processFile ( $ this -> streamFile , $ this -> streamFilePath , $ this -> streamTimestamp , $ this -> streamFileComm...
Close the current stream .
7,117
public function finalize ( ) { if ( ! $ this -> isFinalized ) { if ( strlen ( $ this -> streamFilePath ) > 0 ) { $ this -> closeStream ( ) ; } $ cd = implode ( "" , $ this -> cdRec ) ; $ cdRecSize = pack ( "v" , sizeof ( $ this -> cdRec ) ) ; $ cdRec = $ cd . self :: ZIP_END_OF_CENTRAL_DIRECTORY . $ cdRecSize . $ cdRec...
Close the archive . A closed archive can no longer have new files added to it .
7,118
public function getZipFile ( ) { if ( ! $ this -> isFinalized ) { $ this -> finalize ( ) ; } $ this -> zipflush ( ) ; rewind ( $ this -> zipFile ) ; return $ this -> zipFile ; }
Get the handle ressource for the archive zip file . If the zip haven t been finalized yet this will cause it to become finalized
7,119
public function getZipData ( ) { if ( ! $ this -> isFinalized ) { $ this -> finalize ( ) ; } if ( ! is_resource ( $ this -> zipFile ) ) { return $ this -> zipData ; } else { rewind ( $ this -> zipFile ) ; $ filestat = fstat ( $ this -> zipFile ) ; return fread ( $ this -> zipFile , $ filestat [ 'size' ] ) ; } }
Get the zip file contents If the zip haven t been finalized yet this will cause it to become finalized
7,120
public function getArchiveSize ( ) { if ( ! is_resource ( $ this -> zipFile ) ) { return strlen ( $ this -> zipData ) ; } $ filestat = fstat ( $ this -> zipFile ) ; return $ filestat [ 'size' ] ; }
Return the current size of the archive
7,121
private function getDosTime ( $ timestamp = 0 ) { $ timestamp = ( int ) $ timestamp ; $ oldTZ = @ date_default_timezone_get ( ) ; date_default_timezone_set ( 'UTC' ) ; $ date = ( $ timestamp == 0 ? getdate ( ) : getdate ( $ timestamp ) ) ; date_default_timezone_set ( $ oldTZ ) ; if ( $ date [ "year" ] >= 1980 ) { retur...
Calculate the 2 byte dostime used in the zip entries .
7,122
public static function generateExtAttr ( $ owner = 07 , $ group = 05 , $ other = 05 , $ isFile = true ) { $ fp = $ isFile ? self :: S_IFREG : self :: S_IFDIR ; $ fp |= ( ( $ owner & 07 ) << 6 ) | ( ( $ group & 07 ) << 3 ) | ( $ other & 07 ) ; return ( $ fp << 16 ) | ( $ isFile ? self :: S_DOS_A : self :: S_DOS_D ) ; }
Create the file permissions for a file or directory for use in the extFileAttr parameters .
7,123
public static function getFileExtAttr ( $ filename ) { if ( file_exists ( $ filename ) ) { $ fp = fileperms ( $ filename ) << 16 ; return $ fp | ( is_dir ( $ filename ) ? self :: S_DOS_D : self :: S_DOS_A ) ; } return FALSE ; }
Get the file permissions for a file or directory for use in the extFileAttr parameters .
7,124
private static function getTemporaryFile ( ) { if ( is_callable ( self :: $ temp ) ) { $ temporaryFile = @ call_user_func ( self :: $ temp ) ; if ( is_string ( $ temporaryFile ) && strlen ( $ temporaryFile ) && is_writable ( $ temporaryFile ) ) { return $ temporaryFile ; } } $ temporaryDirectory = ( is_string ( self ::...
Returns the path to a temporary file .
7,125
public function validate ( $ field , $ data = NULL , $ flags = 0x000000 ) { $ key = $ this -> getKey ( $ field ) ; if ( isset ( $ this -> dataProvider ) ) { $ data = $ this -> dataProvider -> getValidatorData ( $ field ) ; } if ( $ this -> hasField ( $ field ) ) { try { foreach ( $ this -> rules [ $ key ] as $ rule ) {...
Validiert die Daten zu einem Feld
7,126
public function setLightAmbientColor ( $ red , $ green , $ blue ) { $ this -> lightAmbientColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the ambient color in which elements reflect the light
7,127
public function setCloudsMinimumColor ( $ red , $ green , $ blue ) { $ this -> cloudsMinimumColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the minimum value for the background color range
7,128
public function setCloudsMaximumColor ( $ red , $ green , $ blue ) { $ this -> cloudsMaximumColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the maximum value for the background color range
7,129
public function setLight0Color ( $ red , $ green , $ blue ) { $ this -> light0Color = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the RGB color of light source 0
7,130
public function setLightBallColor ( $ red , $ green , $ blue ) { $ this -> lightBallColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the light ball color
7,131
public function setFogColor ( $ red , $ green , $ blue ) { $ this -> fogColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the fog color
7,132
public function setSelfIlluminationColor ( $ red , $ green , $ blue ) { $ this -> selfIlluminationColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
Set the self illumination color
7,133
public function addSkyGradient ( $ x , $ color ) { $ skyGradientKey = new SkyGradientKey ( $ x , $ color ) ; return $ this -> addSkyGradientKey ( $ skyGradientKey ) ; }
Add a sky gradient
7,134
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "mood" ) ; if ( $ this -> lightAmbientColor ) { $ domElement -> setAttribute ( "LAmbient_LinearRgb" , $ this -> lightAmbientColor ) ; } if ( $ this -> cloudsMinimumColor ) { $ domElement -> setAttribute ( "CloudsRgb...
Render the Mood
7,135
public function store ( $ table ) { $ table = config ( 'center.tables.' . $ table ) ; if ( ! isset ( $ table -> name ) ) { return redirect ( ) -> action ( '\LeftRight\Center\Controllers\TableController@index' ) -> with ( 'error' , trans ( 'center::site.table_does_not_exist' ) ) ; } $ inserts = self :: processColumnsInp...
save a new object instance to the database
7,136
public static function listColumn ( $ table ) { if ( is_string ( $ table ) ) $ table = config ( 'center.tables.' . $ table ) ; $ fields = ! empty ( $ table -> list ) ? $ table -> list : array_keys ( ( array ) $ table -> fields ) ; foreach ( $ fields as $ field ) { if ( $ table -> fields -> { $ field } -> type == 'strin...
get the first text field column name
7,137
public function setBorderSize ( $ pValue = null ) { $ this -> _borderTopSize = $ pValue ; $ this -> _borderLeftSize = $ pValue ; $ this -> _borderRightSize = $ pValue ; $ this -> _borderBottomSize = $ pValue ; $ this -> _borderInsideHSize = $ pValue ; $ this -> _borderInsideVSize = $ pValue ; }
Set TLRBVH Border Size
7,138
public function getBorderSize ( ) { $ t = $ this -> getBorderTopSize ( ) ; $ l = $ this -> getBorderLeftSize ( ) ; $ r = $ this -> getBorderRightSize ( ) ; $ b = $ this -> getBorderBottomSize ( ) ; $ h = $ this -> getBorderInsideHSize ( ) ; $ v = $ this -> getBorderInsideVSize ( ) ; return array ( $ t , $ l , $ r , $ b...
Get TLRBVH Border Size
7,139
public function getBorderColor ( ) { $ t = $ this -> getBorderTopColor ( ) ; $ l = $ this -> getBorderLeftColor ( ) ; $ r = $ this -> getBorderRightColor ( ) ; $ b = $ this -> getBorderBottomColor ( ) ; $ h = $ this -> getBorderInsideHColor ( ) ; $ v = $ this -> getBorderInsideVColor ( ) ; return array ( $ t , $ l , $ ...
Get TLRB Border Color
7,140
public static function create ( ) { $ arguments = func_get_args ( ) ; $ name = array_shift ( $ arguments ) ; $ class_name = "Core\\CCShipyard_" . ucfirst ( $ name ) ; if ( ! class_exists ( $ class_name ) ) { throw new CCException ( "CCShipyard - invalid builder (" . $ name . ") given." ) ; } $ builder = new $ class_nam...
Static call wrapper to require the right builder
7,141
private function hasValidCacheItem ( CacheItemInterface $ cacheItem , array $ fieldList ) : bool { $ data = $ cacheItem -> get ( ) ; if ( is_null ( $ data ) ) { return false ; } $ fieldDiff = array_diff ( $ fieldList , array_keys ( $ data ) ) ; return ! $ fieldDiff ; }
Has valid cache item .
7,142
private function getCacheItemGenerator ( SearchCriteriaInterface $ searchCriteria ) { try { foreach ( $ searchCriteria -> getIdList ( ) as $ item ) { $ cacheKey = $ this -> keyGenerator -> generate ( $ item , $ searchCriteria ) ; yield $ item => $ this -> cacheItemPool -> getItem ( $ cacheKey ) ; } } catch ( PsrCacheIn...
Retrieve cache data generator .
7,143
public function get ( $ class ) { if ( $ class instanceof ReflectionClass ) { $ reflection = $ class ; $ class = $ reflection -> getName ( ) ; } if ( isset ( $ this -> utils [ $ class ] ) ) { return $ this -> utils [ $ class ] ; } if ( ! isset ( $ reflection ) ) { if ( ! class_exists ( $ class ) && ! interface_exists (...
Get a utility class
7,144
public function isExpired ( ) { if ( null === $ this -> expiresAt ) { return false ; } $ now = new \ DateTime ( ) ; return $ this -> expiresAt < $ now ; }
Checks whether the cart is expired or not .
7,145
public function addBinding ( $ field , $ values ) { if ( ! is_array ( $ values ) ) { $ values = [ $ values ] ; } foreach ( $ values as $ value ) { if ( $ value instanceof Predicate ) { $ this -> resolvePredicate ( $ value ) ; } else if ( $ value instanceof SubQuery ) { $ this -> resolveSubQuery ( $ value ) ; } else { $...
Add a value to use in SQL parameter binding .
7,146
public function resolvePredicate ( Predicate $ predicate ) { $ this -> _bindings = array_merge ( $ this -> _bindings , $ predicate -> getBindings ( ) ) ; return $ this ; }
Merge an external predicates bindings with the current bindings .
7,147
public function resolveSubQuery ( SubQuery $ query ) { foreach ( $ query -> getGroupedBindings ( ) as $ bindings ) { $ this -> _bindings = array_merge ( $ this -> _bindings , $ bindings ) ; } return $ this ; }
Merge an external sub - queries bindings with the current bindings .
7,148
public function getRootDirModule ( ) { $ r = new \ ReflectionObject ( $ this ) ; $ injectionDir = str_replace ( '\\' , '/' , dirname ( $ r -> getFileName ( ) ) ) ; return $ injectionDir . '/..' ; }
Get Root Dir Module
7,149
public function loadRoutes ( ) { $ routesJsonFile = $ this -> configDir . '/routes.json' ; $ routesPhpFile = $ this -> configDir . '/routes.php' ; if ( file_exists ( $ this -> resourcesDir ) && file_exists ( $ this -> configDir ) ) { if ( file_exists ( $ routesJsonFile ) ) return json_decode ( file_get_contents ( $ rou...
Load routes of the Module
7,150
public function reverseMapPrice ( ? float $ price ) : ? int { if ( null === $ price ) { return null ; } if ( 0.00 === $ price ) { return 0 ; } return ( int ) str_replace ( '.' , '' , number_format ( $ price , 2 , '.' , '' ) ) ; }
Maps price to string .
7,151
public function send ( $ subject , $ content , $ to , $ fromName = '' , $ fromEmail = '' ) { $ mail = new CakeEmail ( ) ; $ fromName = ( $ fromName !== '' ) ? $ fromName : $ this -> _fromName ; $ fromEmail = ( $ fromEmail !== '' ) ? $ fromEmail : $ this -> _fromEmail ; $ transport = new MailTransport ( ) ; return $ mai...
Send message method .
7,152
public function setDependencies ( array $ dependencies ) { $ this -> dependencies = array_values ( array_filter ( $ dependencies , function ( $ dependency ) : bool { return $ dependency instanceof Dependency ; } ) ) ; return $ this ; }
Sets the dependencies of the mod .
7,153
public function restGet ( $ cursor ) { if ( $ cursor instanceof Cursor ) { $ name = $ cursor -> getCollection ( ) -> getName ( ) ; $ criteria = $ cursor -> getCriteria ( ) ; $ limit = $ cursor -> limit ( ) ; $ skip = $ cursor -> skip ( ) ; $ sorts = $ cursor -> sort ( ) ; $ query = array ( ) ; foreach ( $ criteria as $...
Get data from rest service .
7,154
public function addInstallMacroblock ( $ name , $ file , $ url ) { $ macroblockElement = new InstallMacroblock ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ macroblockElement ) ; }
Install a Macroblock
7,155
public function addInstallMap ( $ name , $ url ) { $ mapElement = new InstallMap ( $ name , $ url ) ; return $ this -> addElement ( $ mapElement ) ; }
Install a map
7,156
public function addPlayMap ( $ name , $ url ) { $ mapElement = new PlayMap ( $ name , $ url ) ; return $ this -> addElement ( $ mapElement ) ; }
Play a map
7,157
public function addInstallReplay ( $ name , $ url ) { $ replayElement = new InstallReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
Install a replay
7,158
public function addViewReplay ( $ name , $ url ) { $ replayElement = new ViewReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
View a replay
7,159
public function addPlayReplay ( $ name , $ url ) { $ replayElement = new PlayReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
Play a replay
7,160
public function addInstallSkin ( $ name , $ file , $ url ) { $ skinElement = new InstallSkin ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ skinElement ) ; }
Install a skin
7,161
public function addGetSkin ( $ name , $ file , $ url ) { $ skinElement = new GetSkin ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ skinElement ) ; }
Get a skin
7,162
public function addJoinServer ( $ loginOrIp = null , $ port = null ) { $ serverElement = new JoinServer ( $ loginOrIp , $ port ) ; return $ this -> addElement ( $ serverElement ) ; }
Join a server
7,163
public function addAddFavorite ( $ loginOrIp = null , $ port = null ) { $ favoriteElement = new AddFavorite ( $ loginOrIp , $ port ) ; return $ this -> addElement ( $ favoriteElement ) ; }
Add a server as favorite
7,164
public function addInstallScript ( $ name , $ file , $ url ) { $ scriptElement = new InstallScript ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ scriptElement ) ; }
Install a script
7,165
public function addInstallPack ( $ name , $ file , $ url ) { $ packElement = new InstallPack ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ packElement ) ; }
Install a title pack
7,166
public function addElement ( Element $ element ) { if ( ! in_array ( $ element , $ this -> elements , true ) ) { array_push ( $ this -> elements , $ element ) ; } return $ this ; }
Add a ManiaCode Element
7,167
public function render ( $ echo = false ) { $ domDocument = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ domDocument -> xmlStandalone = true ; $ domElement = $ domDocument -> createElement ( "maniacode" ) ; $ domDocument -> appendChild ( $ domElement ) ; if ( $ this -> disableConfirmation ) { $ domElement -> setAttribute ...
Render the ManiaCode
7,168
private function render ( ) { $ output = '' ; foreach ( $ this -> jobs as $ job ) { $ output .= $ this -> getTaskDefinition ( $ job ) ; } return $ output ; }
Render all the cron jobs .
7,169
public function attach ( $ observer ) { if ( is_array ( $ observer ) ) { if ( ! isset ( $ observer [ 'handler' ] ) || ! isset ( $ observer [ 'event' ] ) || ! is_callable ( $ observer [ 'handler' ] ) ) { return ; } foreach ( $ this -> _observers as $ check ) { if ( is_array ( $ check ) && $ check [ 'event' ] == $ observ...
Attach an observer object
7,170
public function detach ( $ observer ) { $ retval = false ; $ key = array_search ( $ observer , $ this -> _observers ) ; if ( $ key !== false ) { unset ( $ this -> _observers [ $ key ] ) ; $ retval = true ; foreach ( $ this -> _methods as & $ method ) { $ k = array_search ( $ key , $ method ) ; if ( $ k !== false ) { un...
Detach an observer object
7,171
public static function attr ( $ attr = array ( ) ) { $ buffer = " " ; foreach ( $ attr as $ key => $ value ) { $ buffer .= $ key . '="' . $ value . '" ' ; } return substr ( $ buffer , 0 , - 1 ) ; }
generates element attribute string
7,172
public function render ( ) { if ( is_closure ( $ this -> value ) ) { ob_start ( ) ; $ return = call_user_func ( $ this -> value ) ; $ this -> value = ob_get_clean ( ) . $ return ; } return '<' . $ this -> name . static :: attr ( $ this -> attr ) . ( ! is_null ( $ this -> value ) ? '>' . $ this -> value . '</' . $ this ...
render this element
7,173
public function save ( string $ namespace , string $ hash , string $ content ) : void { $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; $ this -> ensureDirectory ( dirname ( $ fileName ) ) ; $ success = false ; if ( ! file_exists ( $ fileName ) || is_writable ( $ fileName ) ) { $ success = file_put_conten...
Saves the content under the specified hash .
7,174
public function load ( string $ namespace , string $ hash ) : ? string { $ result = null ; $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; if ( file_exists ( $ fileName ) && is_readable ( $ fileName ) ) { $ result = file_get_contents ( $ fileName ) ; } return is_string ( $ result ) ? $ result : null ; }
Loads and returns the content of the specified hash if available .
7,175
public function delete ( string $ namespace , string $ hash ) : void { $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; if ( file_exists ( $ fileName ) ) { unlink ( $ fileName ) ; } }
Deletes the content under the specified hash .
7,176
protected function getFileName ( string $ namespace , string $ hash ) : string { $ fileName = implode ( DIRECTORY_SEPARATOR , [ $ this -> directory , $ namespace , substr ( $ hash , 0 , 2 ) , $ hash ] ) ; return $ fileName ; }
Returns the filename to use to save the content with the specified namespace and hash .
7,177
protected function ensureDirectory ( string $ directory ) : void { if ( ! is_dir ( $ directory ) ) { $ success = @ mkdir ( $ directory , 0775 , true ) ; if ( ! $ success && ! is_dir ( $ directory ) ) { throw new ExportDataException ( 'Unable to create directory ' . $ directory . '.' ) ; } } if ( ! is_writable ( $ direc...
Ensures that the specified directory is available and writable .
7,178
public function getAllHashes ( string $ namespace ) : array { $ directory = implode ( DIRECTORY_SEPARATOR , [ $ this -> directory , $ namespace , ] ) ; $ result = [ ] ; if ( is_dir ( $ directory ) ) { $ directoryIterator = new RecursiveDirectoryIterator ( $ directory , RecursiveDirectoryIterator :: SKIP_DOTS ) ; foreac...
Returns all hashes currently known to the adapter .
7,179
protected function delete ( array $ criteria = array ( ) ) { $ conditions = array ( ) ; foreach ( $ criteria as $ field => $ value ) { $ conditions [ ] = "$field = ?" ; } $ sql = "DELETE FROM $this->_table WHERE " . implode ( ' AND ' , $ conditions ) ; $ pdos = $ this -> _pdo -> prepare ( $ sql ) ; $ pdos -> execute ( ...
Function SQL DELETE
7,180
protected function insert ( array $ data = array ( ) ) { $ fields = array ( ) ; $ values = array ( ) ; foreach ( $ data as $ field => $ value ) { $ fields [ ] = $ field ; $ values [ ] = '?' ; } $ sql = "INSERT INTO $this->_table " . "(" . implode ( ', ' , $ fields ) . ")" . "VALUES (" . implode ( ', ' , $ values ) . ")...
Function SQL INSERT
7,181
protected function select ( array $ fields , array $ criteria = array ( ) , array $ operators = array ( ) , array $ conditions = array ( ) ) { $ sql = "" ; $ stringConditions = array ( ) ; if ( ( ! empty ( $ criteria ) && ! empty ( $ operators ) ) && ! empty ( $ conditions ) ) { if ( ( count ( $ criteria ) == count ( $...
Function SQL SELECT
7,182
protected function update ( array $ data = array ( ) , array $ criteria ) { $ set = array ( ) ; foreach ( $ data as $ columnName => $ value ) { $ set [ ] = "$columnName = ?" ; } $ params = array_merge ( array_values ( $ data ) , array_values ( $ criteria ) ) ; $ sql = "UPDATE $this->_table SET " . implode ( ', ' , $ se...
Function SQL UPDATE
7,183
protected function prepareDatabaseEcosystem ( ) { $ basePath = realpath ( '../' ) ; $ dbPath = $ basePath . '/' . $ this -> options [ 'dbPath' ] . '/' . $ this -> options [ 'database' ] ; if ( ! is_dir ( $ dbPath ) ) { mkdir ( $ dbPath , 0755 , true ) ; } $ this -> dbPath = realpath ( $ dbPath ) ; }
Prepare database file and folder structure .
7,184
public function getCollectionData ( $ collection , $ criteria = null ) { if ( is_null ( $ this -> dbPath ) ) { $ this -> prepareDatabaseEcosystem ( ) ; } if ( ! is_dir ( $ this -> dbPath . '/' . $ collection ) ) { mkdir ( $ this -> dbPath . '/' . $ collection , 0755 , true ) ; } $ rows = array ( ) ; if ( $ handle = ope...
Getter for specific data for collection
7,185
protected function writeDeclaration ( ClassDeclaration $ declaration , string $ type = null ) { $ type = $ type ?? static :: ELEMENT ; $ filename = $ this -> config -> classFilename ( $ type , $ this -> argument ( 'name' ) ) ; $ filename = $ this -> files -> normalizePath ( $ filename ) ; if ( $ this -> files -> exists...
Write declaration into file .
7,186
public function insert ( $ sessionId , $ clientId ) { $ this -> session_id = $ sessionId ; $ this -> client_id = $ clientId ; $ this -> time = time ( ) ; $ ret = $ this -> _db -> insertObject ( $ this -> _tbl , $ this , 'session_id' ) ; if ( ! $ ret ) { $ this -> setError ( JText :: sprintf ( 'JLIB_DATABASE_ERROR_STORE...
Insert a session
7,187
public function update ( $ updateNulls = false ) { $ this -> time = time ( ) ; $ ret = $ this -> _db -> updateObject ( $ this -> _tbl , $ this , 'session_id' , $ updateNulls ) ; if ( ! $ ret ) { $ this -> setError ( JText :: sprintf ( 'JLIB_DATABASE_ERROR_STORE_FAILED' , strtolower ( get_class ( $ this ) ) , $ this -> ...
Updates the session
7,188
public function destroy ( $ userId , $ clientIds = array ( ) ) { $ clientIds = implode ( ',' , $ clientIds ) ; $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'userid' ) . ' = ' . $ this -> _db -> quote ( $ userId ) ) -> wh...
Destroys the pre - existing session
7,189
public function purge ( $ maxLifetime = 1440 ) { $ past = time ( ) - $ maxLifetime ; $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'time' ) . ' < ' . ( int ) $ past ) ; $ this -> _db -> setQuery ( $ query ) ; return $ thi...
Purge old sessions
7,190
public function exists ( $ userid ) { $ query = $ this -> _db -> getQuery ( true ) -> select ( 'COUNT(userid)' ) -> from ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'userid' ) . ' = ' . $ this -> _db -> quote ( $ userid ) ) ; $ this -> _db -> setQuery ( $ query ) ; if ( ! $...
Find out if a user has one or more active sessions
7,191
public function delete ( $ oid = null ) { $ k = $ this -> _tbl_key ; if ( $ oid ) { $ this -> $ k = $ oid ; } $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( $ this -> _tbl_key ) . ' = ' . $ this -> _db -> quote ( $ this ->...
Overloaded delete method
7,192
public function setModelId ( $ modelId ) { $ this -> modelId = ( string ) $ modelId ; $ this -> model = null ; return $ this ; }
Set the FrameModel id
7,193
public function setModel ( FrameModel $ frameModel ) { $ this -> modelId = null ; $ this -> model = $ frameModel ; return $ this ; }
Set the FrameModel
7,194
public static function escapeText ( $ text , $ addApostrophes = true ) { $ dangers = array ( '\\' , '"' , "\n" ) ; $ replacements = array ( '\\\\' , '\\"' , '\\n' ) ; $ escapedText = str_ireplace ( $ dangers , $ replacements , $ text ) ; if ( $ addApostrophes ) { $ escapedText = '"' . $ escapedText . '"' ; } return $ e...
Escape dangerous characters in the given text
7,195
public static function getReal ( $ value ) { $ value = ( float ) $ value ; $ stringVal = ( string ) $ value ; if ( ! fmod ( $ value , 1 ) ) { $ stringVal .= "." ; } return $ stringVal ; }
Get the Real string representation of the given value
7,196
public static function getArray ( array $ array , $ associative = true ) { $ arrayText = "[" ; $ index = 0 ; $ count = count ( $ array ) ; foreach ( $ array as $ key => $ value ) { if ( $ associative ) { $ arrayText .= static :: getValue ( $ key ) ; $ arrayText .= " => " ; } $ arrayText .= static :: getValue ( $ value ...
Get the string representation of the given array
7,197
public static function getValue ( $ value ) { if ( is_string ( $ value ) ) { return static :: escapeText ( $ value ) ; } if ( is_bool ( $ value ) ) { return static :: getBoolean ( $ value ) ; } if ( is_array ( $ value ) ) { return static :: getArray ( $ value ) ; } return $ value ; }
Get the string representation for the given value
7,198
public static function getInclude ( $ file , $ namespace = null ) { if ( ! $ namespace && stripos ( $ file , "." ) === false ) { $ namespace = $ file ; } $ file = static :: escapeText ( $ file ) ; $ includeText = "#Include {$file}" ; if ( $ namespace ) { $ includeText .= " as {$namespace}" ; } return $ includeText . ""...
Get the include command for the given file and namespace
7,199
public function getByCriteria ( $ collection , $ criteria ) { if ( $ data = $ this -> findOne ( $ collection , $ criteria ) ) { $ obj = $ this -> container -> get ( $ this -> classMap -> getClassForResult ( $ collection , $ data ) ) ; $ obj -> setCollection ( $ collection ) ; $ obj -> loadFromArray ( $ data ) ; return ...
convenience method to retrieve object by criteria should be used in public static method by the derived class