idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
58,600
|
public function getPdoType ( $ type , $ value ) { if ( null === $ value ) { $ type = \ PDO :: PARAM_NULL ; } else { switch ( $ type ) { case AbstractEntity :: TYPE_BOOL : $ type = \ PDO :: PARAM_BOOL ; break ; case AbstractEntity :: TYPE_INT : $ type = \ PDO :: PARAM_INT ; break ; default : $ type = \ PDO :: PARAM_STR ; } } return $ type ; }
|
Get PDO parameter type for given RIO property type
|
58,601
|
protected function setDB ( \ Native5 \ Core \ Database \ DB $ db ) { if ( empty ( $ db ) ) throw new \ InvalidArgumentException ( "Emoty DB object received" ) ; $ this -> db = $ db ; }
|
setDB Set the DB connection to use
|
58,602
|
protected function setDBFromConfigurationArray ( $ dbConfigArray ) { $ dbConfigFactory = new \ Native5 \ Core \ Database \ DBConfigFactory ( ) ; $ dbConfigFactory -> setRawConfig ( $ dbConfigArray ) ; $ this -> db = \ Native5 \ Core \ Database \ DBFactory :: makeDB ( $ dbConfigFactory -> getConfig ( ) ) ; }
|
setDBFromConfigurationArray Create and Set the DB connection using parameters in assoc . array
|
58,603
|
protected function loadQueries ( $ sqlQueriesFile ) { if ( ! file_exists ( $ sqlQueriesFile ) ) throw new \ Exception ( "File with mysql queries not found at expected location: $sqlQueriesFile" ) ; if ( ! ( $ this -> queries = \ Symfony \ Component \ Yaml \ Yaml :: parse ( file_get_contents ( $ sqlQueriesFile ) ) ) ) throw new \ Exception ( "Could not parse yaml file with mysql queries: $sqlQueriesFile" ) ; }
|
setYamlQueries Set the name of the yaml file with sql queries indexed by query names
|
58,604
|
protected function execQuery ( $ queryIndex , $ valArr , $ type = \ Native5 \ Core \ Database \ DB :: SELECT ) { return $ this -> db -> execQuery ( $ this -> queries [ $ queryIndex ] , $ valArr , $ type ) ; }
|
execQuery Execute Indexed Query
|
58,605
|
protected function execQueryString ( $ query , $ valArr , $ type = \ Native5 \ Core \ Database \ DB :: SELECT ) { return $ this -> db -> execQuery ( $ query , $ valArr , $ type ) ; }
|
execQueryString Execute Query String
|
58,606
|
public function __async_upload ( ) { $ fsModule = $ this -> system -> module ( 'fs' ) ; $ upload = new Upload ( array ( ) , $ _GET [ 'i' ] ) ; $ upload -> upload ( $ file_path ) ; if ( class_exists ( '\samson\scale\ScaleController' , false ) && $ this -> isImage ( $ fsModule -> extension ( $ file_path ) ) ) { $ scale = $ this -> system -> module ( 'scale' ) ; $ scale -> resize ( $ upload -> fullPath ( ) , $ upload -> name ( ) , $ upload -> uploadDir ) ; } $ urlPath = $ upload -> path ( ) . $ upload -> name ( ) ; $ this -> createField ( new dbQuery ( ) , $ _GET [ 'e' ] , $ _GET [ 'f' ] , $ _GET [ 'i' ] ) ; $ this -> field -> save ( $ urlPath ) ; return array ( 'status' => 1 , 'path' => $ urlPath ) ; }
|
Upload file controller
|
58,607
|
public function __async_delete ( ) { $ fsModule = $ this -> system -> module ( 'fs' ) ; $ this -> createField ( new dbQuery ( ) , $ _GET [ 'e' ] , $ _GET [ 'f' ] , $ _GET [ 'i' ] ) ; $ file = $ this -> field -> value ( ) ; if ( class_exists ( '\samson\scale\ScaleController' , false ) && $ this -> isImage ( $ fsModule -> extension ( $ file ) ) ) { $ path = '' ; preg_match ( '/.*\//' , $ file , $ path ) ; $ path = $ path [ 0 ] ; $ src = substr ( $ file , strlen ( $ path ) ) ; $ scale = m ( 'scale' ) ; foreach ( array_keys ( $ scale -> thumnails_sizes ) as $ folder ) { $ imageScalePath = $ path . $ folder . '/' . $ src ; if ( $ fsModule -> exists ( $ imageScalePath ) ) { $ fsModule -> delete ( $ imageScalePath ) ; } } } if ( $ fsModule -> exists ( $ file ) ) { $ fsModule -> delete ( $ file ) ; } $ this -> field -> save ( ' ' ) ; return array ( 'status' => true ) ; }
|
Delete file controller
|
58,608
|
public function build ( $ params ) { return ( ( isset ( $ params [ 'scheme' ] ) ) ? $ params [ 'scheme' ] . '://' : '' ) . ( ( isset ( $ params [ 'user' ] ) ) ? $ params [ 'user' ] . ( ( isset ( $ params [ 'pass' ] ) ) ? ':' . $ params [ 'pass' ] : '' ) . '@' : '' ) . ( ( isset ( $ params [ 'host' ] ) ) ? $ params [ 'host' ] : '' ) . ( ( isset ( $ params [ 'port' ] ) ) ? ':' . $ params [ 'port' ] : '' ) . ( ( isset ( $ params [ 'path' ] ) ) ? $ params [ 'path' ] : '' ) . ( ( isset ( $ params [ 'query' ] ) ) ? '?' . $ params [ 'query' ] : '' ) . ( ( isset ( $ params [ 'fragment' ] ) ) ? '#' . $ params [ 'fragment' ] : '' ) ; }
|
Reverse of the PHP built - in function parse_url
|
58,609
|
public function encode ( $ input ) { $ chars = [ 'Ă' => 'a' , 'ă' => 'a' , 'Â' => 'A' , 'â' => 'a' , 'Î' => 'I' , 'î' => 'i' , 'Ș' => 'S' , 'ș' => 's' , 'Ş' => 'S' , 'ş' => 's' , 'Ț' => 'T' , 'ț' => 't' , 'Ţ' => 'T' , 'ţ' => 't' ] ; $ change = $ with = [ ] ; foreach ( $ chars as $ i => $ v ) { $ change [ ] = html_entity_decode ( $ i , ENT_QUOTES , 'UTF-8' ) ; $ with [ ] = $ v ; } $ input = str_replace ( $ change , $ with , $ input ) ; preg_match_all ( "/[a-z0-9]+/i" , $ input , $ sections ) ; return strtolower ( implode ( "-" , $ sections [ 0 ] ) ) ; }
|
Replaces all non - alphanumeric characters and returns dash - separated string
|
58,610
|
public function onRequestError ( Event $ event ) { $ e = $ this -> factory -> fromResponse ( $ event [ 'request' ] , $ event [ 'response' ] ) ; $ event -> stopPropagation ( ) ; throw $ e ; }
|
Convert generic Guzzle exceptions into Kinvey - specific exceptions .
|
58,611
|
public function expand ( ) : IP { $ result = clone $ this ; if ( $ this -> isIPv6 ) { $ bytes = unpack ( 'n*' , inet_pton ( $ this -> address ) ) ; $ result -> address = implode ( ':' , array_map ( function ( $ b ) { return sprintf ( '%04x' , $ b ) ; } , $ bytes ) ) ; } return $ result ; }
|
Returns a fully expanded representation of the IP address .
|
58,612
|
public function compact ( ) : IP { $ result = clone $ this ; if ( $ this -> isIPv6 ) { $ result -> address = inet_ntop ( inet_pton ( $ this -> address ) ) ; } return $ result ; }
|
Returns a compact representation of the IP address .
|
58,613
|
public function isPrivate ( ) : bool { if ( $ this -> isLoopback ( ) ) { return true ; } $ filtered = filter_var ( $ this -> address , FILTER_VALIDATE_IP , FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ; return $ filtered === false ; }
|
Checks if the IP is a private IP address .
|
58,614
|
public function isInRange ( string $ range ) : bool { $ targetRange = strtolower ( $ range ) ; $ myIP = bin2hex ( inet_pton ( $ this -> address ) ) ; if ( strpos ( $ targetRange , '-' ) !== false ) { $ parts = explode ( '-' , $ targetRange ) ; if ( count ( $ parts ) > 2 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid range "%s" given.' , $ range ) ) ; } $ firstIP = bin2hex ( inet_pton ( trim ( $ parts [ 0 ] ) ) ) ; $ lastIP = bin2hex ( inet_pton ( trim ( $ parts [ 1 ] ) ) ) ; return $ myIP >= $ firstIP && $ myIP <= $ lastIP ; } elseif ( strpos ( $ targetRange , '/' ) !== false ) { $ parts = explode ( '/' , $ targetRange ) ; if ( count ( $ parts ) > 2 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid range "%s" given.' , $ range ) ) ; } if ( strpos ( $ parts [ 0 ] , '.' ) !== false ) { $ x = explode ( '.' , trim ( $ parts [ 0 ] ) ) ; while ( count ( $ x ) < 4 ) { $ x [ ] = '0' ; } $ firstIP = bin2hex ( inet_pton ( implode ( '.' , $ x ) ) ) ; $ variableBits = 32 - $ parts [ 1 ] ; $ pos = 7 ; } else { $ firstIP = bin2hex ( inet_pton ( trim ( $ parts [ 0 ] ) ) ) ; $ variableBits = 128 - $ parts [ 1 ] ; $ pos = 31 ; } $ lastIP = $ firstIP ; while ( $ variableBits > 0 ) { $ oldValue = hexdec ( substr ( $ lastIP , $ pos , 1 ) ) ; $ newValue = $ oldValue | ( pow ( 2 , min ( 4 , $ variableBits ) ) - 1 ) ; $ lastIP = substr_replace ( $ lastIP , dechex ( $ newValue ) , $ pos , 1 ) ; $ variableBits -= 4 ; $ pos -= 1 ; } return $ myIP >= $ firstIP && $ myIP <= $ lastIP ; } else { try { $ targetIP = new self ( $ targetRange ) ; return $ this -> isEqualTo ( $ targetIP ) ; } catch ( \ InvalidArgumentException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid range "%s" given.' , $ range ) ) ; } } }
|
Checks whether this IP is in the given range or not .
|
58,615
|
private function isLoopback ( ) : bool { if ( $ this -> isIPv6 ) { return $ this -> compact ( ) -> address == '::1' ; } return ( ip2long ( $ this -> address ) & 0xff000000 ) == 0x7f000000 ; }
|
Checks if the IP is a known loopback address .
|
58,616
|
public function setTemplateVariable ( $ name , $ value ) { $ this -> initViewModel ( ) ; $ this -> viewModel -> setVariable ( $ name , $ value ) ; return $ this ; }
|
Set view variable
|
58,617
|
public function setVariables ( $ variables , $ overwrite = false ) { $ this -> initViewModel ( ) ; try { $ this -> viewModel -> setVariables ( $ variables , $ overwrite ) ; } catch ( Exception \ InvalidArgumentException $ e ) { throw new Exception \ InvalidArgumentException ( $ e -> getMessage ( ) ) ; } }
|
Set view variables en masse
|
58,618
|
public function initTwig ( ) { if ( $ this -> twig ) return ; Twig_Autoloader :: register ( ) ; $ this -> twig = new Twig_Environment ( ) ; $ loader = new Twig_Loader_Filesystem ( dirname ( $ this -> path ) ) ; $ this -> twig -> setLoader ( $ loader ) ; }
|
initialize twig .
|
58,619
|
static function assertLooselyIdentical ( $ expected , $ actual , bool $ canonicalizeKeys = false , string $ message = '' ) : void { static :: assertThat ( $ actual , static :: looselyIdenticalTo ( $ expected , $ canonicalizeKeys ) , $ message ) ; }
|
Assert that two values have the same type and value but consider different instances of the same class identical as long as they have identical properties
|
58,620
|
static function assertSameIterable ( iterable $ expected , $ actual , string $ message = '' ) : void { static :: assertThat ( $ actual , static :: identicalIterable ( $ expected ) , $ message ) ; }
|
Assert that two iterables contain the same values and types in the same order
|
58,621
|
static function assertLooselyIdenticalIterable ( iterable $ expected , $ actual , bool $ canonicalizeKeys = false , string $ message = '' ) { static :: assertThat ( $ actual , static :: looselyIdenticalIterable ( $ expected , $ canonicalizeKeys ) , $ message ) ; }
|
Assert that two iterables contain the same values and types in the same order but consider different instances of the same class identical as long as they have identical properties
|
58,622
|
static function assertEqualIterable ( iterable $ expected , $ actual , string $ message = '' ) : void { static :: assertThat ( $ actual , static :: equalIterable ( $ expected ) , $ message ) ; }
|
Assert that two iterables contain equal values in any order
|
58,623
|
public function blameBus ( $ file , $ line ) { $ blameCommand = sprintf ( "-L%s,%s --line-porcelain -- %s" , $ line , $ line , $ file ) ; return $ this -> command ( 'blame' , $ blameCommand ) ; }
|
Returns information on the last edit of a file and line .
|
58,624
|
protected function command ( $ command , $ args ) { $ command = trim ( sprintf ( 'git %s %s' , $ command , Stringify :: arguments ( $ args ) ) ) ; list ( $ output , $ return ) = $ this -> execute ( $ command ) ; if ( $ return != self :: SUCCESS ) { throw new CommandFailureException ( $ output ) ; } if ( is_array ( $ output ) ) { return array_map ( 'trim' , $ output ) ; } return trim ( $ output ) ; }
|
Returns output from a command .
|
58,625
|
public function delete ( $ id ) { if ( $ ids = $ this -> db -> ids ( array ( 'SELECT node.id' , 'FROM ' . $ this -> table . ' AS node, ' . $ this -> table . ' AS parent' , 'WHERE node.lft BETWEEN parent.lft AND parent.rgt AND parent.' . $ this -> id . ' = ?' , 'ORDER BY node.lft' , ) , $ id ) ) { $ this -> db -> exec ( 'DELETE FROM ' . $ this -> table . ' WHERE ' . $ this -> id . ' IN(' . implode ( ', ' , $ ids ) . ')' ) ; return $ ids ; } return false ; }
|
Delete a node and all of it s children from your hierarchical table .
|
58,626
|
public function id ( $ field , array $ values ) { $ from = array ( ) ; $ where = array ( ) ; foreach ( range ( 1 , count ( $ values ) ) as $ level => $ num ) { $ from [ ] = ( isset ( $ previous ) ) ? "{$this->table} AS t{$num} ON t{$num}.parent = t{$previous}.{$this->id}" : "{$this->table} AS t{$num}" ; $ where [ ] = "t{$num}.level = {$level} AND t{$num}.{$field} = ?" ; $ previous = $ num ; } return $ this -> db -> value ( "SELECT t{$num}.{$this->id} \nFROM " . implode ( "\n LEFT JOIN " , $ from ) . "\nWHERE " . implode ( "\n AND " , $ where ) , $ values ) ; }
|
Get the id of a given path .
|
58,627
|
public function path ( $ field , $ value , $ column = null ) { if ( is_null ( $ column ) ) { $ column = $ field ; } $ single = ( ! is_array ( $ column ) ) ? $ column : false ; $ path = array ( ) ; if ( $ stmt = $ this -> db -> query ( array ( 'SELECT parent.' . $ this -> id . ', ' . $ this -> fields ( 'parent' , ( array ) $ column ) , 'FROM ' . $ this -> table . ' AS node' , 'INNER JOIN ' . $ this -> table . ' AS parent' , 'WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.' . $ field . ' = ?' , 'ORDER BY node.lft' , ) , $ value , 'assoc' ) ) { while ( $ row = $ this -> db -> fetch ( $ stmt ) ) { $ path [ array_shift ( $ row ) ] = ( $ single ) ? $ row [ $ single ] : $ row ; } $ this -> db -> close ( $ stmt ) ; } return $ path ; }
|
Retrieve a single path .
|
58,628
|
public function children ( $ id , $ column ) { $ single = ( ! is_array ( $ column ) ) ? $ column : false ; $ children = array ( ) ; if ( $ stmt = $ this -> db -> query ( 'SELECT ' . $ this -> id . ', ' . implode ( ', ' , ( array ) $ column ) . ' FROM ' . $ this -> table . ' WHERE parent = ? ORDER BY lft' , $ id , 'assoc' ) ) { while ( $ row = $ this -> db -> fetch ( $ stmt ) ) { $ children [ array_shift ( $ row ) ] = ( $ single ) ? $ row [ $ single ] : $ row ; } $ this -> db -> close ( $ stmt ) ; } return $ children ; }
|
Find the immediate subordinates of a node ie . no grand children .
|
58,629
|
public function counts ( $ table , $ match , $ id = null ) { if ( ! is_null ( $ id ) ) { return ( int ) $ this -> db -> value ( array ( 'SELECT COUNT(' . $ table . '.' . $ match . ') AS count' , 'FROM ' . $ this -> table . ' AS node' , 'INNER JOIN ' . $ this -> table . ' AS parent' , 'INNER JOIN ' . $ table , 'WHERE parent.' . $ this -> id . ' = ' . ( int ) $ id . ' AND node.lft BETWEEN parent.lft AND parent.rgt AND node.' . $ this -> id . ' = ' . $ table . '.' . $ match , 'GROUP BY parent.' . $ this -> id , 'ORDER BY parent.lft' , ) ) ; } else { $ counts = array ( ) ; if ( $ stmt = $ this -> db -> query ( array ( 'SELECT parent.' . $ this -> id . ', COUNT(' . $ table . '.' . $ match . ') AS count' , 'FROM ' . $ this -> table . ' AS node' , 'INNER JOIN ' . $ this -> table . ' AS parent' , 'INNER JOIN ' . $ table , 'WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.' . $ this -> id . ' = ' . $ table . '.' . $ match , 'GROUP BY parent.' . $ this -> id , 'ORDER BY parent.lft' , ) ) ) { while ( list ( $ id , $ count ) = $ this -> db -> fetch ( $ stmt ) ) { $ counts [ $ id ] = ( int ) $ count ; } $ this -> db -> close ( $ stmt ) ; } return $ counts ; } }
|
Aggregate the total records in a table for each tree node .
|
58,630
|
public function tree ( $ column , $ field = null , $ value = null , $ having = null ) { $ tree = array ( ) ; if ( func_num_args ( ) >= 3 ) { $ depth = ( is_string ( $ having ) && strpos ( $ having , 'depth' ) !== false ) ? ' HAVING ' . $ having : null ; $ stmt = $ this -> db -> query ( array ( 'SELECT node.' . $ this -> id . ', ' . $ this -> fields ( 'node' , ( array ) $ column ) . ', node.parent, (COUNT(parent.' . $ this -> id . ') - (sub_tree.sub_depth + 1)) AS depth' , 'FROM ' . $ this -> table . ' AS node' , 'INNER JOIN ' . $ this -> table . ' AS parent' , 'INNER JOIN ' . $ this -> table . ' AS sub_parent' , 'INNER JOIN (' , ' SELECT node.' . $ this -> id . ', (COUNT(parent.' . $ this -> id . ') - 1) AS sub_depth' , ' FROM ' . $ this -> table . ' AS node' , ' INNER JOIN ' . $ this -> table . ' AS parent' , ' WHERE node.lft BETWEEN parent.lft AND parent.rgt' , ' AND node.' . $ field . ' = ?' , ' GROUP BY node.' . $ this -> id , ' ORDER BY node.lft' , ') AS sub_tree' , 'WHERE node.lft BETWEEN parent.lft AND parent.rgt' , ' AND node.lft BETWEEN sub_parent.lft AND sub_parent.rgt' , ' AND sub_parent.' . $ this -> id . ' = sub_tree.' . $ this -> id , 'GROUP BY node.' . $ this -> id . $ depth , 'ORDER BY node.lft' , ) , $ value , 'assoc' ) ; } else { $ depth = ( is_string ( $ field ) && strpos ( $ field , 'depth' ) !== false ) ? ' HAVING ' . $ field : null ; $ stmt = $ this -> db -> query ( array ( 'SELECT node.' . $ this -> id . ', ' . $ this -> fields ( 'node' , ( array ) $ column ) . ', node.parent, (COUNT(parent.' . $ this -> id . ') - 1) AS depth' , 'FROM ' . $ this -> table . ' AS node' , 'INNER JOIN ' . $ this -> table . ' AS parent' , 'WHERE node.lft BETWEEN parent.lft AND parent.rgt' , 'GROUP BY node.' . $ this -> id . $ depth , 'ORDER BY node.lft' , ) , '' , 'assoc' ) ; } while ( $ row = $ this -> db -> fetch ( $ stmt ) ) { $ tree [ array_shift ( $ row ) ] = $ row ; } $ this -> db -> close ( $ stmt ) ; return $ tree ; }
|
Retrieve a full tree or any parts thereof .
|
58,631
|
public function lister ( array $ tree , array $ nest = null ) { if ( is_null ( $ nest ) ) { return $ this -> lister ( $ tree , $ this -> nestify ( $ tree ) ) ; } $ list = array ( ) ; foreach ( $ nest as $ id => $ values ) { if ( ! empty ( $ values ) ) { $ list [ array_shift ( $ tree [ $ id ] ) ] = $ this -> lister ( $ tree , $ values ) ; } else { $ list [ ] = array_shift ( $ tree [ $ id ] ) ; } } return $ list ; }
|
Create a multi - dimensional array using the first value of each tree array .
|
58,632
|
public function flatten ( array $ nest , array $ related = array ( ) ) { $ children = array ( ) ; foreach ( $ nest as $ id => $ values ) { $ parents = $ related ; $ parents [ ] = $ id ; if ( ! empty ( $ values ) ) { foreach ( $ this -> flatten ( $ values , $ parents ) as $ nest ) { $ children [ ] = $ nest ; } } else { $ children [ ] = $ parents ; } } return $ children ; }
|
Flatten a nested tree .
|
58,633
|
private function traverse ( $ id , $ level = - 1 ) { $ lft = $ this -> count ; ++ $ this -> count ; if ( isset ( $ this -> parents [ $ id ] ) ) { foreach ( $ this -> parents [ $ id ] as $ child ) { $ this -> traverse ( $ child , $ level + 1 ) ; } unset ( $ this -> parents [ $ id ] ) ; } $ rgt = $ this -> count ; ++ $ this -> count ; $ this -> update [ $ id ] = array ( 'level' => $ level , 'lft' => $ lft , 'rgt' => $ rgt ) ; }
|
Used to refresh the database .
|
58,634
|
public function getLocaleFromAuthenticatedUser ( ) { $ user = $ this -> findAuthenticatedUser ( ) ; return ( null !== $ user && $ user -> getLocale ( ) ) ? $ user -> getLocale ( ) : 'es' ; }
|
Get locale from authenticated user
|
58,635
|
public function encodeReversibleString ( $ string ) { $ salt = $ this -> getSecretAppString ( ) ; $ key = substr ( base64_encode ( $ salt ) , 0 , 50 ) ; $ iv = '12345678' ; $ cc = base64_encode ( json_encode ( array ( 'time' => strrev ( '' . time ( ) ) , 'key' => $ string , 'random' => rand ( 10000000 , 99999999 ) ) ) ) ; $ cipher = mcrypt_module_open ( MCRYPT_BLOWFISH , '' , 'cbc' , '' ) ; mcrypt_generic_init ( $ cipher , $ key , $ iv ) ; $ encrypted = mcrypt_generic ( $ cipher , $ cc ) ; mcrypt_generic_deinit ( $ cipher ) ; return base64_encode ( $ encrypted ) ; }
|
Encode an string with a reversible algorithm
|
58,636
|
public function decodeReversibleString ( $ string ) { $ salt = $ this -> getSecretAppString ( ) ; $ key = substr ( base64_encode ( $ salt ) , 0 , 50 ) ; $ iv = '12345678' ; $ cc = base64_decode ( $ string ) ; $ cipher = mcrypt_module_open ( MCRYPT_BLOWFISH , '' , 'cbc' , '' ) ; mcrypt_generic_init ( $ cipher , $ key , $ iv ) ; $ decrypted = mdecrypt_generic ( $ cipher , $ cc ) ; mcrypt_generic_deinit ( $ cipher ) ; return json_decode ( base64_decode ( $ decrypted ) , true ) [ 'key' ] ; }
|
Decode an string with a reversible algorithm
|
58,637
|
public function encodeHashOfString ( $ string ) { $ salt = $ this -> getServiceContainer ( ) -> getParameter ( 'secret' ) ; $ key = substr ( base64_encode ( $ salt ) , 0 , 30 ) ; $ options = array ( 'cost' => 13 , 'salt' => $ key ) ; $ hash = hash ( 'sha512' , password_hash ( $ string , PASSWORD_BCRYPT , $ options ) ) ; return $ hash ; }
|
Encode an string with in a irreversible hash
|
58,638
|
private function activateCheckMode ( InputInterface $ input ) { $ this -> check = $ input -> getOption ( 'check' ) ; $ this -> start = microtime ( true ) ; }
|
Activate check mode but only if the check option was given and note the execution start time .
|
58,639
|
private function reportChange ( OutputInterface $ output ) { $ this -> end = microtime ( true ) ; $ output -> writeLn ( sprintf ( '[DROID-RESULT] %s' , json_encode ( array ( 'changed' => $ this -> change , 'start' => $ this -> start , 'end' => $ this -> end , ) ) ) ) ; }
|
Write the result of the check to the supplied OutputInterface .
|
58,640
|
public static function add ( string $ p_ns , \ FreeFW \ Interfaces \ DependencyInjectorInterface $ p_di ) { self :: $ containers [ $ p_ns ] = $ p_di ; }
|
Add new DI
|
58,641
|
public static function registerDI ( string $ p_ns , \ FreeFW \ Application \ Config $ p_config , \ Psr \ Log \ LoggerInterface $ p_logger ) { $ di = \ FreeFW \ DI \ DependencyInjector :: getFactory ( $ p_ns , $ p_config , $ p_logger ) ; self :: add ( $ p_ns , $ di ) ; return $ di ; }
|
Register new DI
|
58,642
|
public static function getShared ( string $ p_name ) { if ( array_key_exists ( $ p_name , self :: $ shared ) ) { return self :: $ shared [ $ p_name ] ; } return false ; }
|
Get shared object
|
58,643
|
public static function fixPath ( string $ path ) : string { if ( false !== strpos ( $ path , '\\' ) ) { $ path = str_replace ( '\\' , '/' , $ path ) ; } while ( false !== strpos ( $ path , '//' ) ) { $ path = str_replace ( '//' , '/' , $ path ) ; } if ( strlen ( $ path ) ) { if ( '/' === substr ( $ path , 0 , 1 ) ) { $ path = ltrim ( $ path , '/' ) ; } if ( '/' === substr ( $ path , - 1 , 1 ) ) { $ path = rtrim ( $ path , '/' ) ; } } return $ path ; }
|
Fix slashes and backslashes in path .
|
58,644
|
public function process ( ContainerBuilder $ container ) { $ this -> container = $ container ; foreach ( $ container -> getDefinitions ( ) as $ id => $ definition ) { if ( $ definition -> isSynthetic ( ) || $ definition -> isAbstract ( ) ) { continue ; } $ this -> currentId = $ id ; $ this -> validateReferences ( $ definition -> getArguments ( ) ) ; $ this -> validateReferences ( $ definition -> getMethodCalls ( ) ) ; $ this -> validateReferences ( $ definition -> getProperties ( ) ) ; } }
|
Processes the ContainerBuilder to validate References .
|
58,645
|
private function validateReferences ( array $ arguments ) { foreach ( $ arguments as $ argument ) { if ( is_array ( $ argument ) ) { $ this -> validateReferences ( $ argument ) ; } elseif ( $ argument instanceof Reference ) { $ targetDefinition = $ this -> getDefinition ( ( string ) $ argument ) ; if ( null !== $ targetDefinition && $ targetDefinition -> isAbstract ( ) ) { throw new RuntimeException ( sprintf ( 'The definition "%s" has a reference to an abstract definition "%s". ' . 'Abstract definitions cannot be the target of references.' , $ this -> currentId , $ argument ) ) ; } } } }
|
Validates an array of References .
|
58,646
|
private function getDefinition ( $ id ) { if ( ! $ this -> container -> hasDefinition ( $ id ) ) { return ; } return $ this -> container -> getDefinition ( $ id ) ; }
|
Returns the Definition given an id .
|
58,647
|
public function mutateAttribute ( $ key , $ value ) { if ( $ this -> hasGetMutator ( $ key ) ) { return parent :: mutateAttribute ( $ key , $ value ) ; } return $ this -> getAttribute ( $ key ) ; }
|
Get alias value from mutator or directly from attribute
|
58,648
|
public function checkToken ( ) { if ( \ Config :: get ( 'tiga.skip_csrf_protect' , false ) ) return ; if ( $ this -> session -> get ( 'tiga_csrf_token' , false ) == false ) { throw new \ Exception ( 'Invalid csrf token' ) ; } $ input = $ this -> input ( '_tiga_token' ) ; if ( $ this -> isXmlHttpRequest ( ) ) { $ input = $ this -> headers -> get ( 'X-CSRF-Tiga-Token' ) ; } if ( $ this -> session -> get ( 'tiga_csrf_token' ) != $ input ) { throw new \ Exception ( 'Invalid csrf token' ) ; } }
|
Check request token and throw exception if token is not found .
|
58,649
|
protected function getBrowserCommand ( $ url ) { if ( \ Tivie \ OS \ MACOSX == $ this -> os -> getType ( ) ) { return "open $url" ; } if ( $ this -> os -> isWindowsLike ( ) ) { return "start $url" ; } return "xdg-open $url" ; }
|
Find the right command to launch a url on a platform .
|
58,650
|
public function normalize ( $ name ) { if ( $ name instanceof RawExpressionInterface ) { return ( string ) $ name ; } return implode ( '.' , array_map ( function ( $ value ) { return $ value === '*' ? $ value : '"' . $ value . '"' ; } , explode ( '.' , $ name ) ) ) ; }
|
Normalize the name for PGSQL Quotes are put around all the words which are divided with dot as PG is case sensitive
|
58,651
|
private static function validateReleaseFormatForHyphen ( $ name ) { if ( ! stristr ( $ name , '-' ) ) { throw new \ Exception ( 'Release must include a hyphen' ) ; } if ( strpos ( $ name , '-' ) === 0 ) { throw new \ Exception ( 'Hyphen cannot be first character' ) ; } if ( strpos ( $ name , '-' ) === ( strlen ( $ name ) - 1 ) ) { throw new \ Exception ( 'Hyphen cannot be last character' ) ; } }
|
Validate given release name for hyphen position
|
58,652
|
public static function validateReleaseFormat ( $ name ) { self :: validateReleaseFormatForHyphen ( $ name ) ; list ( $ adjective , $ noun ) = explode ( '-' , $ name ) ; if ( $ adjective [ 0 ] != $ noun [ 0 ] ) { throw new \ Exception ( 'Invalid combination of release name: ' . $ name ) ; } }
|
Validate format of release name
|
58,653
|
public static function randomFor ( $ char ) { return new Release ( implode ( '-' , array ( \ ReleaseName \ Component \ Adjective :: randomFor ( $ char ) , \ ReleaseName \ Component \ Noun :: randomFor ( $ char ) ) ) ) ; }
|
Get random release name for given character
|
58,654
|
protected function dispatch ( string $ aggregateId , PayloadInterface $ payload , array $ metaData = null ) : void { $ this -> getCommandDispatcher ( ) -> dispatch ( new CommandMessage ( $ payload , new PayloadType ( $ payload ) , $ aggregateId , $ metaData ) ) ; }
|
Dispatch new command message .
|
58,655
|
public function newAction ( Request $ request ) { $ page = new Page ( ) ; $ form = $ this -> createForm ( 'CoreBundle\Form\PageType' , $ page , array ( 'translator' => $ this -> get ( 'translator' ) ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ page ) ; $ em -> flush ( $ page ) ; if ( $ request -> isXMLHttpRequest ( ) ) { return new JsonResponse ( array ( 'id' => $ page -> getId ( ) , ) ) ; } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'page.created' ) ; return $ this -> redirectToRoute ( 'core_page_index' ) ; } return array ( 'page' => $ page , 'form' => $ form -> createView ( ) , ) ; }
|
Creates a new page entity .
|
58,656
|
private function createDeleteForm ( Page $ page ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'core_page_delete' , array ( 'id' => $ page -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
|
Creates a form to delete a page entity .
|
58,657
|
public function logIn ( string $ password , string $ hash , array $ user ) : bool { if ( ! $ user || ! password_verify ( $ password , $ hash ) ) { return false ; } $ this -> session -> set ( 'user' , $ user ) ; return true ; }
|
Logs a user in
|
58,658
|
public function logInRememberMe ( array $ user ) : bool { if ( ! $ user ) { return false ; } $ this -> session -> set ( 'user' , $ user ) ; return true ; }
|
Logs a user in using the remember me cookie
|
58,659
|
public function needsRehash ( string $ hash ) : bool { if ( ! $ this -> isLoggedIn ( ) ) { return false ; } return password_needs_rehash ( $ hash , PASSWORD_DEFAULT , [ 'cost' => self :: PASSWORD_COST ] ) ; }
|
Checks whether the user s password needs to be rehashed
|
58,660
|
public function isAdmin ( ) : bool { return $ this -> isLoggedIn ( ) && isset ( $ this -> session -> get ( 'user' ) [ 'admin' ] ) && $ this -> session -> get ( 'user' ) [ 'admin' ] === true ; }
|
Checks whether the current user is an administrator
|
58,661
|
public function foreign ( $ datas = [ ] ) { if ( ! array_key_exists ( 'type' , $ datas ) ) { throw new MissingEntityException ( 'The parameter "type" is missing for the foreign key' ) ; } if ( ! array_key_exists ( 'reference' , $ datas ) ) { throw new MissingEntityException ( 'The parameter "reference" is missing for the foreign key' ) ; } if ( ! array_key_exists ( 'belong' , $ datas ) ) { $ datas [ 'belong' ] = ForeignKey :: AGGREGATION ; } if ( ! array_key_exists ( 'current' , $ datas ) || count ( $ datas [ 'current' ] ) < 2 ) { $ datas [ 'current' ] = [ $ this -> entity , $ this -> name ] ; } if ( ! array_key_exists ( 'value' , $ datas ) ) { $ datas [ 'value' ] = '' ; } if ( ! array_key_exists ( 'join' , $ datas ) ) { $ datas [ 'join' ] = Builder :: JOIN_INNER ; } $ this -> foreign = new ForeignKey ( $ datas ) ; return $ this ; }
|
Set foreigns key
|
58,662
|
public function FormatContent ( $ Log ) { $ Data = $ Log [ 'Data' ] ; switch ( $ Log [ 'RecordType' ] ) { case 'Activity' : $ Result = $ this -> FormatKey ( 'Story' , $ Data ) ; break ; case 'Discussion' : $ Result = '<b>' . $ this -> FormatKey ( 'Name' , $ Data ) . '</b><br />' . $ this -> FormatKey ( 'Body' , $ Data ) ; break ; case 'ActivityComment' : case 'Comment' : $ Result = $ this -> FormatKey ( 'Body' , $ Data ) ; break ; case 'Configuration' : $ Result = $ this -> FormatConfiguration ( $ Data ) ; break ; case 'Registration' : case 'User' : $ Result = $ this -> FormatRecord ( array ( 'Email' , 'Name' ) , $ Data ) ; if ( $ DiscoveryText = GetValue ( 'DiscoveryText' , $ Data ) ) { $ Result .= '<br /><b>' . T ( 'Why do you want to join?' ) . '</b><br />' . Gdn_Format :: Display ( $ DiscoveryText ) ; } if ( GetValue ( 'Banned' , $ Data ) ) { $ Result .= "<br />" . T ( 'Banned' ) ; } break ; default : $ Result = '' ; } return $ Result ; }
|
Format the content of a log file .
|
58,663
|
public function GetOperationCount ( $ Operation ) { if ( $ Operation == 'edits' ) $ Operation = array ( 'edit' , 'delete' ) ; else $ Operation = explode ( ',' , $ Operation ) ; sort ( $ Operation ) ; array_map ( 'ucfirst' , $ Operation ) ; $ CacheKey = 'Moderation.LogCount.' . implode ( '.' , $ Operation ) ; $ Count = Gdn :: Cache ( ) -> Get ( $ CacheKey ) ; if ( $ Count === Gdn_Cache :: CACHEOP_FAILURE ) { $ Count = $ this -> GetCountWhere ( array ( 'Operation' => $ Operation ) ) ; Gdn :: Cache ( ) -> Store ( $ CacheKey , $ Count , array ( Gdn_Cache :: FEATURE_EXPIRY => 300 ) ) ; } return $ Count ; }
|
Wrapper for GetCountWhere that takes care of caching specific operation counts .
|
58,664
|
public function dumpTask ( Option $ option ) { $ databases = $ this -> getDatabases ( $ option ) ; $ start = microtime ( true ) ; foreach ( $ databases as $ alias => $ database ) { $ manager = $ this -> getManager ( $ alias , $ database ) ; $ schemaFile = $ this -> migrationHelper -> getSchemaFile ( $ alias ) ; $ this -> console -> log ( $ schemaFile ) ; $ dump = $ manager -> dumpSchema ( $ this -> application -> getEnv ( ) ) ; $ this -> console -> log ( $ dump ) ; if ( file_put_contents ( $ schemaFile , $ dump ) === false ) { $ this -> sendMessage ( 'can not write schema file. -> %s' , $ schemaFile ) ; } $ schemaYAMLFile = $ this -> migrationHelper -> getSchemaYAMLFile ( $ alias ) ; $ this -> console -> log ( $ schemaYAMLFile ) ; $ dump = $ manager -> dumpSchemaYAML ( $ this -> application -> getEnv ( ) ) ; $ this -> console -> log ( $ dump ) ; if ( file_put_contents ( $ schemaYAMLFile , $ dump ) === false ) { $ this -> sendMessage ( 'can not write schema yaml file. -> %s' , $ schemaYAMLFile ) ; } } $ end = microtime ( true ) ; $ this -> sendMessage ( '' ) ; $ this -> sendMessage ( 'All Done. Took %.4fs' , $ end - $ start ) ; }
|
database schema dump task .
|
58,665
|
public function loadTask ( Option $ option ) { $ databases = $ this -> getDatabases ( $ option ) ; $ start = microtime ( true ) ; foreach ( $ databases as $ alias => $ database ) { $ manager = $ this -> getManager ( $ alias , $ database ) ; $ schemaFile = $ this -> migrationHelper -> getSchemaFile ( $ alias ) ; $ this -> console -> log ( $ schemaFile ) ; try { $ this -> sendMessage ( 'schema loading... -> %s' , $ schemaFile ) ; $ manager -> loadSchema ( $ this -> application -> getEnv ( ) , $ schemaFile ) ; } catch ( \ Exception $ e ) { $ this -> sendMessage ( $ e -> getMessage ( ) ) ; $ this -> sendMessage ( 'has error. aborting.' ) ; return ; } } $ end = microtime ( true ) ; $ this -> sendMessage ( '' ) ; $ this -> sendMessage ( 'All Done. Took %.4fs' , $ end - $ start ) ; }
|
database schema load task .
|
58,666
|
public function getManager ( $ alias , Database $ database ) { $ reporter = $ this -> getReporter ( ) ; $ config = new Config ( [ ] ) ; $ config -> setContainer ( $ this -> raikiri ( ) ) ; $ config -> initialize ( $ alias , $ database ) ; $ env = $ config -> getEnvironment ( $ this -> application -> getEnv ( ) ) ; $ reporter -> writeln ( '<info>using migration path</info> ' . $ config -> getMigrationPath ( ) ) ; $ reporter -> writeln ( '<info>using environment</info> ' . $ this -> application -> getEnv ( ) ) ; $ reporter -> writeln ( '<info>using adapter</info> ' . $ env [ 'adapter' ] ) ; $ reporter -> writeln ( '<info>using database</info> ' . $ env [ 'name' ] ) ; $ manager = new Manager ( $ config , new ArrayInput ( [ ] ) , $ reporter ) ; $ manager -> setContainer ( $ this -> raikiri ( ) ) ; return $ manager ; }
|
get migration manager .
|
58,667
|
protected function getDatabases ( Option $ option ) { if ( $ option -> get ( 'database' ) === 'all' ) { $ databases = $ this -> onikiri -> getDatabases ( ) ; } else { $ alias = $ option -> get ( 'database' ) ; $ databases = [ $ alias => $ this -> onikiri -> getDatabase ( $ alias ) ] ; } return $ databases ; }
|
get target databases
|
58,668
|
protected function _setValidationErrors ( $ errorList ) { if ( ! is_null ( $ errorList ) ) { $ errorList = $ this -> _normalizeIterable ( $ errorList ) ; } $ this -> validationErrors = $ errorList ; }
|
Sets the list of validation errors that this instance should represent .
|
58,669
|
public function getPageCount ( ) : int { return intval ( $ this -> count / $ this -> pageSize ) + ( $ this -> count % $ this -> pageSize == 0 ? 0 : 1 ) ; }
|
Get Page Count .
|
58,670
|
public function hasData ( $ key = '' ) { $ key = $ this -> normalizeKeyName ( $ key ) ; if ( empty ( $ key ) || ! is_string ( $ key ) ) { return ! empty ( $ this -> _data ) ; } return array_key_exists ( $ key , $ this -> _data ) ; }
|
Check if has data on object
|
58,671
|
public function getData ( $ key = '' ) { $ key = $ this -> normalizeKeyName ( $ key ) ; if ( $ key === '' ) { return $ this -> _data ; } return isset ( $ this -> _data [ $ key ] ) ? $ this -> _data [ $ key ] : NULL ; }
|
Retrieve data from object
|
58,672
|
public function setData ( $ key , $ value ) { $ key = $ this -> normalizeKeyName ( $ key ) ; if ( isset ( $ this -> _data [ $ key ] ) ) { if ( $ this -> _data [ $ key ] !== $ value ) { $ this -> _original [ $ key ] = $ this -> _data [ $ key ] ; $ this -> _changes [ $ key ] = $ value ; } } else { $ this -> _changes [ $ key ] = $ value ; } $ this -> _data [ $ key ] = $ value ; return $ this ; }
|
Set object data
|
58,673
|
public function addData ( $ data ) { foreach ( $ data as $ key => $ value ) { $ this -> setData ( $ key , $ value ) ; } return $ this ; }
|
Push data to the object
|
58,674
|
public function unsetData ( $ key ) { $ key = $ this -> normalizeKeyName ( $ key ) ; if ( isset ( $ this -> _data [ $ key ] ) ) { $ this -> _original [ $ key ] = $ this -> _data [ $ key ] ; $ this -> _changes [ $ key ] = NULL ; unset ( $ this -> _data [ $ key ] ) ; } return $ this ; }
|
Unset data on object
|
58,675
|
public function __toArray ( $ attributes = array ( ) ) { if ( empty ( $ attributes ) ) { $ data = $ this -> _data ; } else { $ data = array ( ) ; foreach ( $ attributes as $ attribute ) { if ( isset ( $ this -> _data [ $ attribute ] ) ) { $ data [ $ attribute ] = $ this -> _data [ $ attribute ] ; } else { $ data [ $ attribute ] = NULL ; } } } foreach ( $ data as $ key => $ item ) { if ( $ item instanceof AppObject ) { $ item = $ item -> toArray ( ) ; $ data [ $ key ] = $ item ; } } return $ data ; }
|
Convert object attributes to array
|
58,676
|
public static function bind ( $ key , $ object = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ key => $ object ) { self :: $ bindings [ $ key ] = $ object ; } } else { self :: $ bindings [ $ key ] = $ object ; } }
|
Bind an object to a key in a bindings array .
|
58,677
|
public static function instance ( $ key ) { if ( isset ( self :: $ bindings [ $ key ] ) ) { return self :: $ bindings [ $ key ] ; } return false ; }
|
Grab an instance which has already been bound to this container otherwise we ll return false .
|
58,678
|
public function parentIdInjection ( array & $ materialIds ) { $ this -> query -> className ( 'material' ) -> cond ( 'MaterialID' , $ materialIds ) -> cond ( 'parent_id' , 0 ) -> cond ( 'Active' , 1 ) -> order_by ( 'Modyfied' , 'DESC' ) -> fieldsNew ( 'MaterialID' , $ materialIds ) ; }
|
Function to cut off related and table materials
|
58,679
|
public function psuStates ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_PSU_STATE ) ; if ( ! $ translate ) return $ states ; return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ PSU_STATES ) ; }
|
Get the device s PSU states
|
58,680
|
public function fanStates ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_FAN_STATE ) ; if ( ! $ translate ) return $ states ; return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ FAN_STATES ) ; }
|
Get the device s fan states
|
58,681
|
public function getPattern ( ) { if ( $ this -> _pattern === null ) { $ this -> _pattern = $ this -> extractTag ( 'pattern' ) ; } return $ this -> _pattern ; }
|
Retrieve defined _pattern tag
|
58,682
|
public function getSort ( ) { if ( $ this -> _sort === null ) { $ this -> _sort = ( float ) $ this -> extractTag ( 'sort' , 0 ) ; } return $ this -> _sort ; }
|
Retrieve defined sort tag
|
58,683
|
protected function _translate ( $ string , $ context = null ) { if ( ! ( ( $ translator = $ this -> _getTranslator ( ) ) instanceof StringTranslatorInterface ) ) { return $ string ; } return $ translator -> translate ( $ string , $ context ) ; }
|
Translates a string in the specified context .
|
58,684
|
public function doubleClick ( ) { $ command = $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/doubleclick' , WebDriver_Command :: METHOD_POST , [ 'element' => $ this -> element -> getElementId ( ) ] ) ; $ this -> webDriver -> getDriver ( ) -> curl ( $ command ) ; return $ this ; }
|
Double tap on the touch screen using finger motion events .
|
58,685
|
public function longClick ( ) { $ command = $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/longclick' , WebDriver_Command :: METHOD_POST , [ 'element' => $ this -> element -> getElementId ( ) ] ) ; $ result = $ this -> webDriver -> getDriver ( ) -> curl ( $ command ) ; return $ this ; }
|
Long press on the touch screen using finger motion events .
|
58,686
|
public function scroll ( $ xOffset , $ yOffset ) { $ command = $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/scroll' , WebDriver_Command :: METHOD_POST , [ 'element' => $ this -> element -> getElementId ( ) , 'xoffset' => ( int ) $ xOffset , 'yoffset' => ( int ) $ yOffset , ] ) ; $ this -> webDriver -> getDriver ( ) -> curl ( $ command ) ; return $ this ; }
|
Scroll on the touch screen using finger based motion events . Use this command to start scrolling at a particular screen location .
|
58,687
|
public function flick ( $ xOffset , $ yOffset , $ speed = WebDriver :: SPEED_NORMAL ) { $ command = $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/flick' , WebDriver_Command :: METHOD_POST , [ 'element' => $ this -> element -> getElementId ( ) , 'xoffset' => ( int ) $ xOffset , 'yoffset' => ( int ) $ yOffset , 'speed' => ( int ) $ speed , ] ) ; $ this -> webDriver -> getDriver ( ) -> curl ( $ command ) ; return $ this ; }
|
Flick on the touch screen using finger motion events . This flickcommand starts at a particulat screen location .
|
58,688
|
public function delete ( $ key ) { Arguments :: define ( $ this -> getKeyType ( ) ) -> check ( $ key ) ; $ cloned = array_merge ( $ this -> value ) ; unset ( $ cloned [ $ key ] ) ; return static :: of ( $ cloned ) ; }
|
Return a new Map of the same type without the specified key .
|
58,689
|
public function update ( $ key , callable $ updater , $ default = null ) { return $ this -> insert ( $ key , $ updater ( Maybe :: fromMaybe ( $ default , $ this -> lookup ( $ key ) ) ) ) ; }
|
Attempt to set a field using the provided updater function .
|
58,690
|
protected function timestampUpdate ( ) { $ this -> updated = date ( 'Y-m-d H:i:s' ) ; $ this -> id || $ this -> created = $ this -> updated ; }
|
RedBean update method Fills in the creation and update timestamps
|
58,691
|
public function addCollection ( Collection $ collection ) { $ metadata = $ collection -> getDocumentMetadata ( ) ; $ this -> collectionMapping [ $ metadata -> getName ( ) ] = $ collection ; }
|
Adds a collection to the schema .
|
58,692
|
public function build ( ) : UserAgentNormalizer { return new UserAgentNormalizer ( [ new Normalizer \ BabelFish ( ) , new Normalizer \ IISLogging ( ) , new Normalizer \ LocaleRemover ( ) , new Normalizer \ EncryptionRemover ( ) , new Normalizer \ Mozilla ( ) , new Normalizer \ Linux ( ) , new Normalizer \ KhtmlGecko ( ) , new Normalizer \ HexCode ( ) , new Normalizer \ WindowsNt ( ) , new Normalizer \ Tokens ( ) , new Normalizer \ SerialNumbers ( ) , new Normalizer \ TransferEncoding ( ) , ] ) ; }
|
builds a useragent normalizer chain
|
58,693
|
public function queue ( $ type , JsonArray $ metaData = null ) { $ taskId = $ this -> generateId ( ) ; if ( null === $ metaData ) { $ metaData = new JsonArray ( ) ; } $ metaData -> set ( Task :: SETTING_ID , $ taskId ) -> set ( Task :: SETTING_TYPE , $ type ) -> set ( 'status' , Task :: STATE_PENDING ) -> set ( Task :: SETTING_CREATED_AT , date ( 'c' ) ) ; $ taskFile = new JsonFile ( $ this -> taskIdToFileName ( $ taskId ) , null ) ; $ taskFile -> setData ( $ metaData -> getData ( ) ) ; $ taskFile -> save ( ) ; if ( ! $ this -> createTaskFromMetaData ( $ taskFile ) ) { unlink ( $ taskFile -> getFilename ( ) ) ; throw new \ InvalidArgumentException ( 'Could not create task of type "' . $ metaData -> get ( 'type' ) . '"' ) ; } $ this -> getConfig ( ) -> set ( $ taskId , $ metaData -> getData ( ) ) ; return $ taskId ; }
|
Add the task to the list .
|
58,694
|
public function getNext ( ) { $ idList = $ this -> getIds ( ) ; if ( false === ( $ taskId = current ( $ idList ) ) ) { return null ; } return $ this -> getTask ( $ taskId ) ; }
|
Retrieve the first task from the queue without removing it .
|
58,695
|
public function remove ( $ taskId ) { $ idList = $ this -> getIds ( ) ; if ( in_array ( $ taskId , $ idList ) ) { $ this -> getConfig ( ) -> remove ( $ taskId ) ; unlink ( $ this -> taskIdToFileName ( $ taskId ) ) ; } return $ this ; }
|
Remove a task from the list including it s task file .
|
58,696
|
public function getTask ( $ taskId ) { $ filename = $ this -> taskIdToFileName ( $ taskId ) ; if ( ! file_exists ( $ filename ) ) { return null ; } return $ this -> createTaskFromMetaData ( new JsonFile ( $ filename , null ) ) ; }
|
Retrieve a task .
|
58,697
|
private function createTaskFromMetaData ( JsonArray $ config ) { $ typeName = $ config -> get ( Task :: SETTING_TYPE ) ; if ( $ this -> factory -> isTypeSupported ( $ typeName ) ) { return $ this -> factory -> createInstance ( $ typeName , $ config ) ; } return null ; }
|
Create a task instance from the given MetaData .
|
58,698
|
static function toList ( iterable $ iterable ) : array { return $ iterable instanceof \ Traversable ? iterator_to_array ( $ iterable , false ) : array_values ( $ iterable ) ; }
|
Convert an iterable value to an array with consecutive integer indexes
|
58,699
|
protected function directory ( $ directory = null ) { switch ( $ directory ) { case 'storage' : $ this -> comment ( 'Cleaning assets library in storage.' ) ; $ count = 0 ; foreach ( $ this -> filesystem -> files ( $ this -> directory [ 'storage' ] ) as $ file ) { $ this -> filesystem -> delete ( $ file ) ; $ count ++ ; } $ this -> info ( $ count . ' files removed' ) ; break ; case 'public' : $ this -> comment ( 'Cleaning assets directory in public.' ) ; $ this -> filesystem -> deleteDirectory ( $ this -> directory [ 'public' ] ) ; $ this -> info ( 'Assets directory in public has been removed' ) ; break ; default : $ this -> directory ( 'storage' ) ; $ this -> directory ( 'public' ) ; break ; } }
|
Depends on the directory
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.