idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
6,200
public function expiresIn ( $ tokenAbstract ) { $ token = $ this -> fromAbstract ( $ tokenAbstract ) ; if ( isset ( $ token -> ExpiresAt ) ) { $ expiry = \ DateTime :: createFromFormat ( \ DateTime :: ATOM , $ token -> ExpiresAt ) ; if ( $ expiry ) { $ now = new \ Datetime ; $ expiresIn = $ expiry -> getTimestamp ( ) -...
Gets number of seconds until token expiry time
6,201
public function generateRule ( Rule $ rule ) { if ( $ rule -> getAddress ( ) ) { $ addresses = $ this -> firewall -> constructAddresses ( $ rule -> getAddress ( ) ) ; } else { $ addresses = [ '' ] ; } $ o = array ( ) ; foreach ( $ addresses as $ address ) { $ r = sprintf ( 'ufw %s' , $ rule -> getAction ( ) ) ; if ( $ ...
Generate a ufw rule .
6,202
public function getValues ( ) { $ values = array ( ) ; foreach ( $ this -> fields -> all ( ) as $ name => $ field ) { if ( $ field -> isDisabled ( ) ) { continue ; } if ( ! $ field instanceof Field \ FileFormField && $ field -> hasValue ( ) ) { $ values [ $ name ] = $ field -> getValue ( ) ; } } return $ values ; }
Gets the field values .
6,203
public function getFiles ( ) { if ( ! in_array ( $ this -> getMethod ( ) , array ( 'POST' , 'PUT' , 'DELETE' , 'PATCH' ) ) ) { return array ( ) ; } $ files = array ( ) ; foreach ( $ this -> fields -> all ( ) as $ name => $ field ) { if ( $ field -> isDisabled ( ) ) { continue ; } if ( $ field instanceof Field \ FileFor...
Gets the file field values .
6,204
public function getPhpValues ( ) { $ values = array ( ) ; foreach ( $ this -> getValues ( ) as $ name => $ value ) { $ qs = http_build_query ( array ( $ name => $ value ) , '' , '&' ) ; if ( ! empty ( $ qs ) ) { parse_str ( $ qs , $ expandedValue ) ; $ varName = substr ( $ name , 0 , strlen ( key ( $ expandedValue ) ) ...
Gets the field values as PHP .
6,205
public function getPhpFiles ( ) { $ values = array ( ) ; foreach ( $ this -> getFiles ( ) as $ name => $ value ) { $ qs = http_build_query ( array ( $ name => $ value ) , '' , '&' ) ; if ( ! empty ( $ qs ) ) { parse_str ( $ qs , $ expandedValue ) ; $ varName = substr ( $ name , 0 , strlen ( key ( $ expandedValue ) ) ) ...
Gets the file field values as PHP .
6,206
static function run_interactive ( $ cmd ) { $ descriptors = array ( 0 => array ( "file" , "php://stdin" , "r" ) , 1 => array ( "file" , "php://stdout" , "w" ) , 2 => array ( "file" , "php://stdout" , "w" ) ) ; $ process = proc_open ( $ cmd , $ descriptors , $ pipes ) ; if ( is_resource ( $ process ) ) { $ return_value ...
Execute a command - line command with interaction . This can be used to string together php scripts or other shell commands that require user input .
6,207
static function replace_line_in_file ( String $ filename = '' , String $ line_to_change = '' , String $ change_to = '' ) { $ replacement_made = false ; if ( is_writable ( $ filename ) ) { self :: say ( 'Reading file: ' . $ filename ) ; $ file = file ( $ filename ) ; } else { self :: say ( 'Could not find the file, or i...
Replace a line in a text file .
6,208
static function replace_and_save ( $ oldFile , $ search , $ replace , $ newFile = null ) { $ newFile = ( $ newFile == null ) ? $ oldFile : $ newFile ; $ file = self :: read_file_to_string ( $ oldFile ) ; $ replacing = str_replace ( $ search , $ replace , $ file ) ; self :: create_file ( $ newFile , $ replacing , $ over...
Open haystack find and replace needles save haystack .
6,209
private function buildDriver ( ) { $ driver = $ this -> container -> resolve ( $ this -> buildDriverName ( $ this -> driver ) ) ; if ( $ driver instanceof BootableDriverInterface ) { $ driver -> boot ( $ this -> configs ) ; } return $ driver ; }
builds selected driver
6,210
protected function setProtocol ( $ version ) { if ( ! is_string ( $ version ) ) { throw new InvalidArgumentException ( sprintf ( 'The HTTP protocol version must be a string, received "%s".' , is_object ( $ version ) ? get_class ( $ version ) : gettype ( $ version ) ) ) ; } $ version = trim ( $ version ) ; if ( ! $ vers...
Sets the version of HTTP protocol .
6,211
protected function setHeader ( $ name , $ value ) { $ name = $ this -> prepareHeaderName ( $ name ) ; $ value = $ this -> prepareHeaderValue ( $ value ) ; $ normalized = strtolower ( $ name ) ; if ( ! isset ( $ this -> headerNames [ $ normalized ] ) ) { $ this -> headerNames [ $ normalized ] = $ name ; } $ header = $ t...
Sets the header .
6,212
protected function addHeader ( $ name , $ value ) { $ name = $ this -> prepareHeaderName ( $ name ) ; $ value = $ this -> prepareHeaderValue ( $ value ) ; $ normalized = strtolower ( $ name ) ; if ( ! isset ( $ this -> headerNames [ $ normalized ] ) ) { $ this -> headerNames [ $ normalized ] = $ name ; } $ header = $ t...
Add the header .
6,213
public function removeHeader ( $ name ) { $ normalized = strtolower ( trim ( $ name ) ) ; if ( ! isset ( $ this -> headerNames [ $ normalized ] ) ) { return $ this ; } $ header = $ this -> headerNames [ $ normalized ] ; unset ( $ this -> rawHeaders [ $ header ] ) ; unset ( $ this -> headerNames [ $ normalized ] ) ; ret...
Removes the header .
6,214
protected function prepareHeaderName ( $ name ) { if ( ! is_string ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid header name "%s" provided; must be an string.' , $ name ) ) ; } $ name = trim ( $ name ) ; if ( ! $ name ) { throw new InvalidArgumentException ( 'Header name is empty.' ) ; } if ( !...
Prepares the header name .
6,215
protected function prepareHeaderValue ( $ value ) { if ( is_string ( $ value ) ) { $ value = [ $ value ] ; } if ( ! is_array ( $ value ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid header value "%s"; must be a string or array of strings.' , is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ val...
Prepares the header value .
6,216
public function add ( $ field , DataSetTransformerInterface $ transformer ) { if ( $ this -> has ( $ field ) ) { throw new TransformerInvalidColumnException ( $ field ) ; } $ this -> items [ $ field ] = $ transformer ; }
Adds new field transformer to collection
6,217
public function disconnect ( $ drop = false ) { if ( is_resource ( $ this -> socket ) ) { fclose ( $ this -> socket ) ; } else { $ this -> logger -> warning ( "Socket is not resource in $this - cannot close it." ) ; } $ this -> logger -> info ( "Listener $this closed" ) ; throw new NodeDisconnectException ( $ this ) ; ...
Closes listener .
6,218
public function set ( $ args ) { $ data [ 'args' ] = func_get_args ( ) ; $ caller = debug_backtrace ( ) ; $ data [ 'caller' ] = $ caller [ 0 ] ; $ data [ 'formated_time' ] = strftime ( '%Y-%m-%d %H:%M:%S' , time ( ) ) ; $ data [ 'formated_microtime' ] = sprintf ( "%'03d" , microtime ( ) * 1000 ) ; return $ this -> _get...
Logs data to the log file .
6,219
protected function _getOutputPlain ( $ data ) { $ output = 'date: ' . $ data [ 'formated_time' ] . ' .' . $ data [ 'formated_microtime' ] . "\n" ; $ output .= 'call: ' . $ data [ 'caller' ] [ 'file' ] . ' (line ' . $ data [ 'caller' ] [ 'line' ] . ')' . "\n" ; foreach ( $ data [ 'args' ] as $ arg ) { $ output .= '---' ...
Formates the output to write it to the file .
6,220
public static function forge ( $ data = array ( ) , $ new = true , $ view = null , $ cache = true ) { return new static ( $ data , $ new , $ view , $ cache ) ; }
Create a new model instance
6,221
public static function connection ( $ writeable = false ) { $ class = get_called_class ( ) ; if ( $ writeable and property_exists ( $ class , '_write_connection' ) ) { return static :: $ _write_connection ; } return property_exists ( $ class , '_connection' ) ? static :: $ _connection : null ; }
Fetch the database connection name to use
6,222
public static function table ( ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _table_names_cached ) ) { if ( property_exists ( $ class , '_table_name' ) ) { static :: $ _table_names_cached [ $ class ] = static :: $ _table_name ; } else { static :: $ _table_names_cached [ $ class ] ...
Get the table name for this class
6,223
public static function condition ( $ type = null ) { $ class = get_called_class ( ) ; if ( property_exists ( $ class , '_conditions' ) ) { if ( $ type !== null ) { return isset ( static :: $ _conditions [ $ type ] ) ? static :: $ _conditions [ $ type ] : array ( ) ; } else { return static :: $ _conditions ; } } else { ...
Get a defined condition for this class
6,224
public static function cached_object ( $ obj , $ class = null ) { $ class = $ class ? : get_called_class ( ) ; $ id = ( is_int ( $ obj ) or is_string ( $ obj ) ) ? ( string ) $ obj : $ class :: implode_pk ( $ obj ) ; $ result = ( ! empty ( static :: $ _cached_objects [ $ class ] [ $ id ] ) ) ? static :: $ _cached_objec...
Attempt to retrieve an earlier loaded object
6,225
public static function implode_pk ( $ data ) { if ( count ( static :: $ _primary_key ) == 1 ) { $ p = reset ( static :: $ _primary_key ) ; return ( is_object ( $ data ) ? strval ( $ data -> { $ p } ) : ( isset ( $ data [ $ p ] ) ? strval ( $ data [ $ p ] ) : null ) ) ; } $ pk = '' ; foreach ( static :: $ _primary_key a...
Implode the primary keys within the data into a string
6,226
public static function properties ( ) { $ class = get_called_class ( ) ; if ( array_key_exists ( $ class , static :: $ _properties_cached ) ) { return static :: $ _properties_cached [ $ class ] ; } if ( property_exists ( $ class , '_properties' ) ) { $ properties = static :: $ _properties ; foreach ( $ properties as $ ...
Get the class s properties
6,227
public static function property ( $ key , $ default = null ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _properties_cached ) ) { static :: properties ( ) ; } return \ Arr :: get ( static :: $ _properties_cached [ $ class ] , $ key , $ default ) ; }
Fetches a property description array or specific data from it
6,228
public static function views ( ) { $ class = get_called_class ( ) ; if ( ! isset ( static :: $ _views_cached [ $ class ] ) ) { static :: $ _views_cached [ $ class ] = array ( ) ; if ( property_exists ( $ class , '_views' ) ) { $ views = $ class :: $ _views ; foreach ( $ views as $ k => $ v ) { if ( ! isset ( $ v [ 'col...
Fetch the model s views
6,229
public static function relations ( $ specific = false ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _relations_cached ) ) { $ relations = array ( ) ; foreach ( static :: $ _valid_relations as $ rel_name => $ rel_class ) { if ( property_exists ( $ class , '_' . $ rel_name ) ) { for...
Get the class s relations
6,230
public static function related_class ( $ relation ) { $ class = get_called_class ( ) ; foreach ( static :: $ _valid_relations as $ rel_name => $ rel_class ) { if ( property_exists ( $ class , '_' . $ rel_name ) ) { if ( isset ( static :: $ { '_' . $ rel_name } [ $ relation ] ) ) { return static :: $ { '_' . $ rel_name ...
Get the name of the class that defines a relation
6,231
public static function observers ( $ specific = null , $ default = null ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _observers_cached ) ) { $ observers = array ( ) ; if ( property_exists ( $ class , '_observers' ) ) { foreach ( static :: $ _observers as $ obs_k => $ obs_v ) { if...
Get the class s observers and what they observe
6,232
public static function unregister_observer ( $ name ) { $ class = get_called_class ( ) ; foreach ( static :: observers ( ) as $ key => $ value ) { if ( ( is_array ( $ value ) and $ key == $ name ) or $ value == $ name ) { unset ( static :: $ _observers_cached [ $ class ] [ $ key ] ) ; } } }
Unregister an observer
6,233
public static function find ( $ id = null , array $ options = array ( ) ) { if ( is_null ( $ id ) ) { return func_num_args ( ) === 2 ? static :: query ( $ options ) : null ; } elseif ( $ id === 'all' ) { return static :: query ( $ options ) -> get ( ) ; } elseif ( $ id === 'first' or $ id === 'last' ) { $ query = stati...
Find one or more entries
6,234
public function _update_original ( $ original = null ) { $ original = is_null ( $ original ) ? $ this -> _data : $ original ; $ this -> _original = array_merge ( $ this -> _original , $ original ) ; $ this -> _update_original_relations ( ) ; }
Update the original setting for this object
6,235
public function _update_original_relations ( $ relations = null ) { if ( is_null ( $ relations ) ) { $ this -> _original_relations = array ( ) ; $ relations = $ this -> _data_relations ; } else { foreach ( $ relations as $ key => $ rel ) { unset ( $ this -> _original_relations [ $ rel ] ) ; unset ( $ relations [ $ key ...
Update the original relations for this object
6,236
public function _relate ( $ rels = false ) { if ( $ rels === false ) { return $ this -> _data_relations ; } elseif ( is_array ( $ rels ) ) { if ( $ this -> _frozen ) { throw new FrozenObject ( 'No changes allowed.' ) ; } $ this -> _data_relations = $ rels ; } else { throw new \ FuelException ( 'Invalid input for _relat...
Fetch or set relations on this object To be used only after having fetched them from the database!
6,237
public function __isset ( $ property ) { if ( array_key_exists ( $ property , static :: properties ( ) ) ) { return true ; } elseif ( static :: relations ( $ property ) ) { return true ; } elseif ( $ this -> _get_eav ( $ property , true ) ) { return true ; } elseif ( array_key_exists ( $ property , $ this -> _custom_da...
Check whether a property exists only return true for table columns relations eav and custom data
6,238
protected function create ( ) { if ( ! $ this -> is_new ( ) ) { return false ; } $ this -> observe ( 'before_insert' ) ; $ query = Query :: forge ( get_called_class ( ) , static :: connection ( true ) ) ; $ primary_key = static :: primary_key ( ) ; $ properties = array_keys ( static :: properties ( ) ) ; foreach ( $ pr...
Save using INSERT
6,239
protected function update ( ) { if ( $ this -> is_new ( ) ) { return false ; } if ( ! $ this -> is_changed ( array_keys ( static :: properties ( ) ) ) ) { return true ; } $ this -> observe ( 'before_update' ) ; $ query = Query :: forge ( get_called_class ( ) , static :: connection ( true ) ) ; $ primary_key = static ::...
Save using UPDATE
6,240
protected function add_primary_keys_to_where ( $ query ) { $ primary_key = static :: primary_key ( ) ; foreach ( $ primary_key as $ pk ) { $ query -> where ( $ pk , '=' , $ this -> _original [ $ pk ] ) ; } }
Adds the primary keys in where clauses to the given query .
6,241
public function delete ( $ cascade = null , $ use_transaction = false ) { if ( $ this -> is_new ( ) or $ this -> frozen ( ) ) { return false ; } if ( $ use_transaction ) { $ db = \ Database_Connection :: instance ( static :: connection ( true ) ) ; $ db -> start_transaction ( ) ; } try { $ this -> observe ( 'before_del...
Delete current object
6,242
protected function delete_self ( ) { $ query = Query :: forge ( get_called_class ( ) , static :: connection ( true ) ) -> limit ( 1 ) ; $ primary_key = static :: primary_key ( ) ; foreach ( $ primary_key as $ pk ) { $ query -> where ( $ pk , '=' , $ this -> { $ pk } ) ; } return $ query -> delete ( ) ; }
Deletes this model instance from the database .
6,243
public function reset ( ) { foreach ( $ this -> _original as $ p => $ val ) { $ this -> _data [ $ p ] = $ val ; } }
Reset values to those gotten from the database
6,244
public function observe ( $ event ) { foreach ( $ this -> observers ( ) as $ observer => $ settings ) { $ events = isset ( $ settings [ 'events' ] ) ? $ settings [ 'events' ] : array ( ) ; if ( ( empty ( $ events ) or in_array ( $ event , $ events ) ) and empty ( $ this -> _disabled_events [ $ event ] ) ) { if ( ! clas...
Calls all observers for the current event
6,245
public function is_changed ( $ property = null ) { $ properties = static :: properties ( ) ; $ relations = static :: relations ( ) ; $ property = ( array ) $ property ? : array_merge ( array_keys ( $ properties ) , array_keys ( $ relations ) ) ; foreach ( $ property as $ p ) { if ( isset ( $ properties [ $ p ] ) ) { if...
Compare current state with the retrieved state
6,246
public function from_array ( array $ values ) { foreach ( $ values as $ property => $ value ) { if ( array_key_exists ( $ property , static :: properties ( ) ) and ! in_array ( $ property , static :: primary_key ( ) ) ) { $ this -> _data [ $ property ] = $ value ; } elseif ( array_key_exists ( $ property , static :: re...
Allow populating this object from an array and any related objects
6,247
public function to_object ( $ custom = false , $ recurse = false ) { return ( object ) $ this -> to_array ( $ custom , $ recurse ) ; }
Allow converting this object to a real object
6,248
public function getRequestAsString ( RequestInterface $ request ) { return $ this -> getFormattedQueryParameters ( $ request ) . PHP_EOL . $ this -> getBodyWithHeaders ( $ request ) ; }
Format request to string .
6,249
public function getFormattedQueryParameters ( RequestInterface $ request ) { return $ this -> getString ( $ this -> getQueryParameters ( $ request -> getUri ( ) -> getQuery ( ) ) ) ; }
Format query parameters .
6,250
public function getBodyWithHeaders ( MessageInterface $ stream ) { $ result = sprintf ( '%s%s%s' , $ this -> getString ( $ stream -> getHeaders ( ) ) , PHP_EOL , $ stream -> getBody ( ) -> getContents ( ) ) ; return $ result ; }
Get body with headers .
6,251
protected function getQueryParameters ( $ query ) { $ pairs = explode ( '&' , $ query ) ; $ parameters = [ ] ; foreach ( $ pairs as $ pair ) { if ( '' === trim ( $ pair ) ) { continue ; } $ nameValue = explode ( '=' , $ pair ) ; $ name = urlencode ( $ nameValue [ 0 ] ) ; $ value = urlencode ( $ nameValue [ 1 ] ) ; $ pa...
Get query parameters .
6,252
protected function implodeAssociative ( $ glue , array $ array ) { $ result = '' ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( '|' , $ value ) ; } $ result .= $ key . $ glue . $ value . PHP_EOL ; } return $ result ; }
Implode associative array into string .
6,253
public static function create ( $ post , $ config ) { $ cmd = new CmdUnknown ( $ post , $ config ) ; self :: $ log = new Logger ( $ config -> log_dir , $ config -> log_level ) ; self :: $ log -> debug ( "CommandFactory: post received (json encoded): " . json_encode ( $ post ) ) ; if ( self :: $ commands == null || self...
Factory method to create command instances . New commands should be added to commands_definition . json
6,254
public static function reloadDefinitions ( $ config ) { $ result = self :: reloadFileDefinitions ( __DIR__ . "/commands_definition.json" ) ; if ( $ result ) { self :: $ log -> debug ( "CommandFactory: default commands_definition.json loaded" ) ; } else { self :: $ log -> error ( "CommandFactory: Error loading default c...
Read command definitions from commands_definition . json and custom commands .
6,255
public function process ( array $ coordinates , ImageInterface $ image ) { $ path = $ this -> imageCropper -> crop ( $ image , $ coordinates ) ; $ image -> setCropperCoordinates ( $ coordinates ) ; $ image -> setPath ( $ path ) ; $ this -> imageManager -> save ( ) ; return array ( 'original_path' => $ image -> getOrigi...
Process image crop .
6,256
public static function fields ( $ orderId , $ orderAmount , $ orderName = null , $ orderDesc = null ) { $ fields = self :: gateway ( ) -> endpoint ( array ( 'orderId' => $ orderId , 'orderAmount' => $ orderAmount , 'orderName' => $ orderName , 'orderDesc' => $ orderDesc , ) ) ; foreach ( $ fields as $ key => $ val ) { ...
Render hidden input fields
6,257
protected function injectCacheMetadata ( $ metakey , & $ value , $ class , $ method , $ groups , $ resultMap ) { $ metadata = new \ stdClass ( ) ; $ metadata -> class = $ class ; $ metadata -> method = $ method ; $ metadata -> groups = empty ( $ groups ) ? null : $ groups ; $ metadata -> resultMap = $ resultMap ; if ( ...
Injects cache metadata on the given value
6,258
protected function extractCacheMetadata ( $ metakey , $ value ) { if ( is_array ( $ value ) || $ value instanceof \ ArrayObject ) { if ( ! array_key_exists ( $ metakey , $ value ) ) return null ; return $ value [ $ metakey ] ; } elseif ( is_object ( $ value ) ) { if ( ! property_exists ( $ value , $ metakey ) ) return ...
Extracts cache metadata from the given value
6,259
public function macro ( $ name , Closure $ callback ) { $ this -> macros [ $ name ] = Closure :: bind ( $ callback , $ this , get_class ( ) ) ; return $ this ; }
add a new closure callback function to class with macros
6,260
public static function mobile ( ) { $ agent = strtolower ( user :: agent ( ) ) ; return strpos ( $ agent , 'mobile' ) || strpos ( $ agent , 'android' ) || strpos ( $ agent , 'iphone' ) ; }
check if the users use mobile devices
6,261
protected function selectSQLDriver ( $ connection ) { switch ( strtolower ( $ connection ) ) { case 'mysql' : $ this -> db = [ 'driver' => 'pdo_mysql' , 'host' => env ( 'DB_HOST' , '127.0.0.1' ) , 'port' => env ( 'DB_PORT' , '3306' ) , 'dbname' => env ( 'DB_DATABASE' , 'teamelf' ) , 'user' => env ( 'DB_USERNAME' , 'tea...
select sql driver with DB_CONNECTION
6,262
public function setReference ( $ reference ) { if ( ! is_string ( $ reference ) || strlen ( trim ( $ reference ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid reference, must be a non empty string' ) ; $ this -> reference = $ reference ; }
Set reference of this Payment
6,263
public function setAmount ( $ amount ) { if ( ! is_int ( $ amount ) || $ amount < 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid amount, must be a positive integer' ) ; $ this -> amount = $ amount ; }
Set amount of this Payment
6,264
public function setCurrency ( $ currency ) { if ( ! is_string ( $ currency ) || strlen ( trim ( $ currency ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid currency, must be a non empty string' ) ; $ this -> currency = $ currency ; }
Set currency of this Payment
6,265
public function setDescription ( $ description ) { if ( ! is_string ( $ description ) || strlen ( trim ( $ description ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid description, must be a non empty string' ) ; $ this -> description = $ description ; }
Set description of this Payment
6,266
protected function init ( ) : void { if ( $ this -> initialized ) { return ; } $ this -> initialized = true ; $ this -> log ( "Daemon Initialized" , LOG_INFO , [ "syslog" , STDOUT ] , true ) ; }
To be overridden by child classes
6,267
public function attach ( Collection $ collection , $ type = 'myGedung\Support\Collection' ) { if ( ! is_null ( $ type ) && $ collection instanceof $ type ) { if ( ! $ this -> find ( $ collection -> id ) ) { $ this -> put ( $ collection -> id , $ collection ) ; } } return $ this ; }
Attaches the given collection into the current collection .
6,268
public static function getInstanceAndConnect ( ) { if ( ! is_object ( self :: getInstance ( ) ) ) { return NULL ; } if ( ! self :: $ instance -> tryConnect ( ) ) { return NULL ; } return self :: $ instance ; }
Get instance if all is ok
6,269
public function tryConnect ( ) { if ( $ this -> db_connected ) { return TRUE ; } if ( ! class_exists ( 'mysqli' ) ) { BLog :: addToLog ( $ this -> logsuffix . ': MySQLi class not found' , LL_ERROR ) ; return FALSE ; } $ this -> mysqli = new \ mysqli ( $ this -> db_host , $ this -> db_username , $ this -> db_password , ...
Try to connect
6,270
public function escapeString ( $ s , $ EMPTY_NULL = false ) { if ( ( ! is_string ( $ s ) ) && ( ! is_numeric ( $ s ) ) ) { $ s = '' ; } if ( ( $ EMPTY_NULL ) && ( empty ( $ s ) ) ) { return 'NULL' ; } return '"' . $ this -> mysqli -> real_escape_string ( $ s ) . '"' ; }
Escape string for MySQL queries
6,271
public function queryAndFetch ( $ sql ) { $ q = $ this -> query ( $ sql ) ; if ( empty ( $ q ) ) { return array ( ) ; } $ res = array ( ) ; while ( $ l = ( $ this -> fetch ( $ q ) ) ) { $ res [ ] = $ l ; } return $ res ; }
Query and fetch
6,272
public static function getFromSapi ( string $ sapi ) : Enviroment { if ( in_array ( $ sapi , [ 'cli' , 'phpdbg' ] ) ) { return Enviroment :: CONSOLE ( ) ; } return Enviroment :: HTML ( ) ; }
Devuelve el Enviroment que corresponde a un valor determinado de PHP_SAPI
6,273
public function authenticate ( SecurityContextInterface & $ context ) { $ token = $ this -> generateEmptyToken ( $ this -> getSession ( ) ) ; try { $ this -> userAuthenticationProvider -> loadClientByCredentials ( $ token -> getClient ( ) -> getCredentials ( ) ) ; } catch ( ClientCredentialsNotFoundException $ e ) { $ ...
authenticates a user based on their context
6,274
public function generateNewToken ( ) { $ client = $ this -> getClient ( ) ; $ nodeConfig = $ this -> container -> get ( 'nodeConfig' ) ; $ token = new SecurityToken ( $ client , $ nodeConfig [ 'ymlkey' ] , $ client -> getRoles ( ) ) ; return $ token ; }
generates a new token based on current client
6,275
public function getTempPath ( ) : FilePathInterface { if ( $ this -> tempPath === null ) { $ this -> tempPath = FilePath :: parse ( sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . 'bluemvc' . DIRECTORY_SEPARATOR . sha1 ( $ this -> documentRoot -> __toString ( ) ) . DIRECTORY_SEPARATOR ) ; self :: ensureDirectoryExists ( $...
Returns the path to the application - specific temporary directory .
6,276
public function setCustomItem ( string $ name , $ value ) : void { $ this -> customItems -> set ( $ name , $ value ) ; }
Sets a custom item .
6,277
public function setErrorControllerClass ( string $ errorControllerClass ) : void { if ( ! is_a ( $ errorControllerClass , ErrorControllerInterface :: class , true ) ) { throw new InvalidControllerClassException ( '"' . $ errorControllerClass . '" is not a valid error controller class.' ) ; } $ this -> errorControllerCl...
Sets the error controller class name .
6,278
public function setTempPath ( FilePathInterface $ tempPath ) : void { if ( ! $ tempPath -> isDirectory ( ) ) { throw new InvalidFilePathException ( 'Temp path "' . $ tempPath . '" is not a directory.' ) ; } try { $ this -> tempPath = $ this -> documentRoot -> withFilePath ( $ tempPath ) ; } catch ( FilePathLogicExcepti...
Sets the path to the application - specific temporary directory .
6,279
public function setViewPath ( FilePathInterface $ viewPath ) : void { if ( ! $ viewPath -> isDirectory ( ) ) { throw new InvalidFilePathException ( 'View path "' . $ viewPath . '" is not a directory.' ) ; } try { $ this -> viewPath = $ this -> documentRoot -> withFilePath ( $ viewPath ) ; } catch ( FilePathLogicExcepti...
Sets the view files path .
6,280
protected function setDocumentRoot ( FilePathInterface $ documentRoot ) : void { if ( ! $ documentRoot -> isDirectory ( ) ) { throw new InvalidFilePathException ( 'Document root "' . $ documentRoot . '" is not a directory.' ) ; } if ( ! $ documentRoot -> isAbsolute ( ) ) { throw new InvalidFilePathException ( 'Document...
Sets the document root .
6,281
private function handleError ( RequestInterface $ request , ResponseInterface $ response , \ Throwable $ throwable = null ) : void { $ errorControllerClass = $ this -> getErrorControllerClass ( ) ; if ( $ errorControllerClass !== null ) { $ errorController = new $ errorControllerClass ( ) ; if ( $ throwable !== null ) ...
Handles an error .
6,282
private function throwableToResponse ( \ Throwable $ throwable , ResponseInterface $ response ) : void { $ response -> setStatusCode ( new StatusCode ( StatusCode :: INTERNAL_SERVER_ERROR ) ) ; $ response -> setHeaders ( new HeaderCollection ( ) ) ; $ response -> setContent ( $ this -> throwableToHtml ( $ throwable ) )...
Outputs a throwable to a response .
6,283
private function throwableToHtml ( \ Throwable $ throwable ) : string { if ( ! $ this -> isDebug ) { return '' ; } return "<!DOCTYPE html>\n" . "<html lang=\"en\">\n" . " <head>\n" . " <meta charset=\"utf-8\">\n" . ' <title>' . htmlentities ( $ throwable -> getMessage ( ) ) . "</title>\n" . " <style>\n...
Converts a throwable to html .
6,284
private static function ensureDirectoryExists ( FilePathInterface $ directory ) : void { if ( ! is_dir ( $ directory -> __toString ( ) ) ) { mkdir ( $ directory -> __toString ( ) , 0700 , true ) ; } }
Ensures that a specified directory exists .
6,285
public static function make ( string $ interfaceName ) { if ( self :: $ container === null ) { throw new \ Exception ( "Undefined DI Container" ) ; } try { return self :: $ container -> get ( $ interfaceName ) ; } catch ( \ Exception $ ex ) { echo "Unable to find Interface inside container " . $ ex -> getMessage ( ) ; ...
Makes Object from Container
6,286
public function getSetting ( $ path ) { if ( ! $ this -> hasSetting ( $ path ) ) { return null ; } $ value = $ this -> resolvePath ( $ path ) ; return $ value ; }
Returns the value of the given settings key .
6,287
public function hasSetting ( $ path ) { $ value = $ this -> resolvePath ( $ path ) ; if ( $ value === null ) { return false ; } return true ; }
Returns true if the given settings key exists .
6,288
protected function resolvePath ( $ path ) { $ parts = explode ( '.' , $ path ) ; $ settings = $ this -> settings ; foreach ( $ parts as $ part ) { if ( ! isset ( $ settings [ $ part ] ) ) { return null ; } $ settings = $ settings [ $ part ] ; } return $ settings ; }
Resolves the path in the loaded settings
6,289
public function setSetting ( $ path , $ value ) { if ( $ value === 'false' ) { $ value = false ; } else if ( $ value === 'true' ) { $ value = true ; } else if ( $ value === 'null' ) { $ value = null ; } $ parts = explode ( '.' , $ path ) ; $ settings = $ this -> updateSetting ( $ this -> settings , $ parts , $ value ) ...
Saves a setting in the configuration file .
6,290
protected function updateSetting ( $ settings , $ parts , $ value ) { $ part = current ( array_slice ( $ parts , 0 , 1 ) ) ; if ( ( string ) intval ( $ part ) == $ part ) { $ part = intval ( $ part ) ; } if ( count ( $ parts ) > 0 ) { $ parts = array_slice ( $ parts , 1 ) ; if ( ! isset ( $ settings [ $ part ] ) ) { $ ...
Updates the given setting and adds not - existing configuration nodes to the configuration tree .
6,291
public function addSettingIfNotSet ( $ path , $ value ) { if ( $ this -> hasSetting ( $ path ) ) { return ; } $ this -> setSetting ( $ path , $ value ) ; }
Adds a setting key and value if the setting isn t set .
6,292
private function transformRequest ( Request $ request ) { $ method = $ request -> getMethod ( ) ; $ url = ( string ) $ request -> getUrl ( ) ; $ options = [ 'version' => $ request -> getProtocolVersion ( ) , 'headers' => $ request -> getHeaders ( ) , ] ; if ( $ body = $ request -> getBody ( ) ) { $ options [ 'body' ] =...
Creates a Guzzle Request
6,293
protected static function validUploadedFiles ( array $ uploadedFiles , string $ index = "" ) { foreach ( $ uploadedFiles as $ key => $ file ) { $ _index = "" === $ index ? $ key : ( $ index . "." . $ key ) ; if ( is_array ( $ file ) ) { self :: validUploadedFiles ( $ file , $ _index ) ; continue ; } if ( ! is_subclass_...
Validate uploaded files .
6,294
public function timeout ( $ timeout = null ) { $ this -> timeout = ( null === $ timeout ) ? $ this -> defaultTimeout : $ timeout ; return $ this ; }
Sets timeout .
6,295
public function execute ( ) { $ locator = $ this -> element -> getLocator ( ) ; if ( null === $ this -> callback ) { throw new WebDriver_Exception ( "Wait callback is undefined for element '{$locator}''" ) ; } for ( $ i = 0 ; $ i < $ this -> timeout ; $ i ++ ) { if ( call_user_func ( $ this -> callback , $ this -> elem...
Performs waiting using current callback .
6,296
public function onKernelException ( GetResponseForExceptionEvent $ event ) { if ( $ event -> getException ( ) instanceof DisplayBlockException ) { $ event -> getRequest ( ) -> setRequestFormat ( 'fragment.' . $ event -> getRequest ( ) -> getRequestFormat ( ) ) ; $ event -> setException ( $ event -> getException ( ) -> ...
If exception type is 404 display the Orchestra 404 node instead of Symfony exception
6,297
protected function setCurrentSiteInfo ( $ host , $ path ) { $ path = $ this -> formatPath ( $ path ) ; $ currentSiteId = null ; $ currentLanguage = null ; $ currentAliasId = null ; $ matchingLength = - 1 ; $ matchingSites = $ this -> siteRepository -> findByAliasDomain ( $ host ) ; foreach ( $ matchingSites as $ site )...
Find and set the current site id language and alias id
6,298
public function addFeaturedSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Video not found.' ] ) ; } try { $ this -> doAddFeaturedSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getEr...
Adds FeaturedSkills to Video
6,299
public function addFeaturedTutorialSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Video not found.' ] ) ; } try { $ this -> doAddFeaturedTutorialSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors'...
Adds FeaturedTutorialSkills to Video