idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
4,400
public function add ( $ url , $ parentID = 0 , $ extract = \ false , $ callbackUrl = '' ) { $ data = [ 'url' => $ url , 'save_parent_id' => $ parentID , 'extract' => ( $ extract ? 'True' : 'False' ) , 'callback_url' => $ callbackUrl ] ; return $ this -> post ( 'transfers/add' , $ data , \ false ) ; }
Adds a new transfer to the queue .
4,401
public function cancel ( $ transferIDs ) { if ( is_array ( $ transferIDs ) ) { $ transferIDs = implode ( ',' , $ transferIDs ) ; } $ data = [ 'transfer_ids' => $ transferIDs ] ; return $ this -> post ( 'transfers/cancel' , $ data , \ true ) ; }
Cancels given transfers .
4,402
protected function normalizeAccessToken ( $ access_token ) { if ( ! isset ( $ access_token [ 'expires_in' ] ) && isset ( $ access_token [ 'expires' ] ) ) { $ access_token [ 'expires_in' ] = $ access_token [ 'expires' ] ; unset ( $ access_token [ 'expires' ] ) ; } return parent :: normalizeAccessToken ( $ access_token )...
Facebook does it differently ... again!
4,403
public function get ( $ path , $ default = null ) { $ path = explode ( $ this -> separator , $ path ) ; $ item = & $ this -> item ; foreach ( $ path as $ key ) { if ( ! is_array ( $ item ) ) { return $ default ; } if ( ! array_key_exists ( $ key , $ item ) ) { return $ default ; } $ item = & $ item [ $ key ] ; } return...
Get the value stored under the specified path
4,404
public function remove ( $ path ) { $ path = explode ( $ this -> separator , $ path ) ; $ last = array_pop ( $ path ) ; $ item = & $ this -> item ; foreach ( $ path as $ key ) { if ( array_key_exists ( $ key , $ item ) && is_array ( $ item [ $ key ] ) ) { $ item = & $ item [ $ key ] ; continue ; } return false ; } if (...
Remove a path
4,405
public function unserialize ( $ data ) { $ data = unserialize ( $ data ) ; $ this -> item = $ data [ 'item' ] ; $ this -> separator = $ data [ 'separator' ] ; $ this -> constraint = $ data [ 'constraint' ] ; }
Method inherited from Serializable
4,406
public function isArray ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; if ( $ value === $ this || ! is_array ( $ value ) ) { return false ; } return array_keys ( $ value ) === range ( 0 , count ( $ value ) - 1 ) ; }
Check if the value stored under the specified path is a JSON array
4,407
public function isString ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_string ( $ value ) ; }
Check if the value stored under the specified path is a string
4,408
public function isNumber ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_numeric ( $ value ) ; }
Check if the value stored under the specified path is a number
4,409
public function isNull ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_null ( $ value ) ; }
Check if the value stored under the specified path is a null value
4,410
public function isBoolean ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_bool ( $ value ) ; }
Check if the value stored under the specified path is a boolean value
4,411
private function initRequest ( ) : App { try { $ request = ServerRequestFactory :: fromGlobals ( ) ; $ this -> containers ( ) -> set ( 'request' , $ request ) ; } catch ( \ InvalidArgumentException $ e ) { new Exception ( $ e ) ; } return $ this ; }
Initiate PSR - 7 request object
4,412
private function initResponse ( ) : App { try { $ response = new Response ( ) ; $ this -> containers ( ) -> set ( 'response' , $ response ) ; } catch ( \ InvalidArgumentException $ e ) { new Exception ( $ e ) ; } return $ this ; }
Initiate PSR - 7 response object
4,413
private function initRouter ( ) : App { $ request = $ this -> container ( 'request' ) ; $ response = $ this -> container ( 'response' ) ; $ router = new Router ( $ request , $ response ) ; $ router -> error ( Error :: class ) ; $ this -> containers ( ) -> set ( 'router' , $ router ) ; return $ this ; }
Put route into the container of classes
4,414
public function map ( array $ methods , string $ pattern , $ callable ) : MethodsInterface { $ this -> container ( 'router' ) -> map ( $ methods , $ pattern , $ callable ) ; return $ this ; }
Few methods provided
4,415
private function detectAction ( string $ className , array $ variables = [ ] ) : string { $ action = $ this -> extractActionFromClass ( $ className ) ?? ( $ variables [ 'action' ] [ 0 ] ?? self :: DEFAULT_ACTION ) ; return 'action_' . $ action ; }
Detect action by string name variable or use default
4,416
private function methodCheck ( $ class , string $ action ) : bool { try { if ( ! \ method_exists ( $ class , $ action ) ) { $ className = \ get_class ( $ class ) ; throw new Exception ( "Method \"$action\" is not found in \"$className\"" ) ; } } catch ( Exception $ e ) { return false ; } return true ; }
Check if method exist in required class
4,417
private function exec ( RouteInterface $ route , RequestInterface $ request , ResponseInterface $ response , bool $ error = false ) { $ variables = $ route -> getVariables ( ) ; $ callback = $ route -> getCallback ( ) ; if ( \ is_string ( $ callback ) ) { $ className = $ this -> extractClass ( $ callback ) ; $ class = ...
Here we need to solve how to display the page and if method is not available need to show error
4,418
public function run ( ) : StreamInterface { $ router = $ this -> container ( 'router' ) ; $ request = $ this -> container ( 'request' ) ; $ response = $ this -> container ( 'response' ) ; $ route = $ router -> getRoute ( ) ; return $ this -> exec ( $ route , $ request , $ response ) ; }
Simple runner should parse query and make work on user s class
4,419
public function resolve ( Request $ request , Response $ response ) { $ uriPath = $ this -> calledUri -> path ( $ this -> route -> configuredPath ( ) ) ; $ target = $ this -> route -> target ( ) ; if ( is_callable ( $ target ) ) { return $ target ( $ request , $ response , $ uriPath ) ; } if ( $ target instanceof Targe...
triggers actual logic on this resource
4,420
public function container ( Column \ Container $ column , array $ row ) { $ html = '' ; foreach ( $ column -> getColumns ( ) as $ c ) { $ html .= $ c -> render ( $ row ) . PHP_EOL ; } return $ this -> post ( $ html , $ column , $ row ) ; }
Render a container
4,421
public function boolean ( Column \ Boolean $ column , array $ row ) { $ html = '' ; if ( $ column -> getValue ( $ row ) ) { $ html .= '<i class="fa fa-check"></i>' ; } return $ this -> post ( $ html , $ column , $ row ) ; }
render boolean icon
4,422
public function remote_boolean ( Column \ RemoteBoolean $ column , array $ row ) { $ table = $ column -> getTable ( ) ; $ attributes = [ 'class' => 'ff-remote-boolean make-switch' , 'type' => 'checkbox' , 'data-size' => 'small' , 'value' => true , 'data-id' => $ row [ $ column -> getTable ( ) -> getIdField ( ) ] , 'dat...
render boolean switch
4,423
public function icon ( Column \ Icon $ column , array $ row ) { $ html = '' ; $ html .= '<i class="fa ' . $ column -> getValue ( $ row ) . '"></i>' ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render Icon column
4,424
public function custom ( Column \ Custom $ column , array $ row ) { $ html = call_user_func ( $ column -> getCustom ( ) , $ row ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render custom callable column
4,425
public function text ( Column \ Text $ column , array $ row ) { $ attributes = $ column -> getAttributes ( ) ; if ( $ column -> hasTooltip ( ) ) { $ attributes += [ 'data-placement' => $ column -> getTooltipPosition ( ) , 'data-original-title' => $ column -> getValue ( $ row ) , 'data-toggle' => 'tooltip' ] ; $ html = ...
Render text column
4,426
public function remote_text ( Column \ RemoteText $ column , array $ row ) { $ html = $ this -> text ( $ column , $ row ) ; $ html .= html ( 'input' , [ 'type' => 'text' , 'data-id' => $ row [ $ column -> getTable ( ) -> getIdField ( ) ] , 'data-column' => $ column -> getName ( ) ] ) ; $ html = html ( 'div' , [ 'class'...
Render a text remote
4,427
public function remote_select ( Column \ RemoteSelect $ column , array $ row ) { $ options = html ( 'option' , [ ] , '--' ) ; $ elementValue = $ row [ $ column -> getIndex ( ) ] ; foreach ( $ column -> getOptions ( ) as $ value => $ key ) { $ attr = [ 'value' => $ value ] ; if ( $ value == $ elementValue ) { $ attr [ '...
Render remote Select
4,428
public function link ( Column \ Link $ column , array $ row ) { if ( $ column -> isRemote ( ) ) { $ column -> addAttribute ( 'data-target' , '#' . $ column -> getRemoteId ( ) ) -> addAttribute ( 'data-toggle' , 'modal' ) ; } elseif ( $ column -> isCallback ( ) ) { $ column -> addClass ( 'callback-remote' ) ; } $ html =...
Render link column
4,429
public function button ( Column \ Button $ column , array $ row ) { if ( $ column -> hasOption ( ) ) { $ column -> addClass ( constant ( Style :: class . '::' . $ column -> getOption ( ) ) ) ; } if ( $ column -> hasSize ( ) ) { $ column -> addClass ( constant ( Style :: class . '::' . $ column -> getSize ( ) ) ) ; } $ ...
Render a button
4,430
public function code ( Column \ Code $ column , array $ row ) { $ html = html ( 'code' , [ ] , $ column -> getValue ( $ row ) ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Rendor a code element
4,431
public function pre ( Column \ Pre $ column , array $ row ) { $ html = html ( 'pre' , [ ] , $ column -> getValue ( $ row ) ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render a pre element
4,432
public function strainerSelect ( Column \ Strainer \ Select $ strainer ) { $ element = $ strainer -> getElement ( ) ; $ element -> addStyle ( 'width' , '100%' ) ; $ element -> addClass ( Style :: FORM_ELEMENT_CONTROL ) ; $ options = '' ; if ( $ element -> hasPlaceholder ( ) ) { $ options .= html ( 'option' , [ 'value' ...
Render strainer for a select element
4,433
public function getOrderName ( Order $ order ) : string { if ( preg_match_all ( '/{{(.*)}}/U' , $ scheme = $ this -> getNameScheme ( ) , $ matches ) ) { foreach ( $ matches [ 1 ] as $ index => $ foundSnippet ) { $ foundSnippetName = trim ( $ foundSnippet ) ; $ usedSnippet = $ order -> hasField ( $ foundSnippetName ) ? ...
Returns the name for the order .
4,434
protected function getMIMEType ( $ file ) { $ mime = 'application/octet-stream' ; if ( function_exists ( 'finfo_open' ) && $ info = @ finfo_open ( FILEINFO_MIME ) ) { if ( ( $ mime = @ finfo_file ( $ info , $ file ) ) !== \ false ) { $ mime = explode ( ';' , $ mime ) ; $ mime = trim ( $ mime [ 0 ] ) ; } } return $ mime...
Attempts to get the MIME type of a given file . Required for native file uploads .
4,435
protected function getResponse ( $ response , $ returnBool , $ arrayKey = '' ) { $ response = $ this -> jsonDecode ( $ response ) ; if ( $ response === \ null ) { return \ false ; } if ( $ returnBool ) { return $ this -> getStatus ( $ response ) ; } if ( $ arrayKey ) { if ( isset ( $ response [ $ arrayKey ] ) ) { retur...
Decodes the response and returns the appropriate value
4,436
protected function nativeJsonDecode ( $ string ) { $ result = @ json_decode ( $ string , \ true ) ; if ( ! $ result || JSON_ERROR_NONE !== json_last_error ( ) ) { $ result = \ null ; } return $ result ; }
Decodes a JSON encoded string natively .
4,437
protected function intFloatCompare ( NI $ a , NI $ b ) { return $ this -> rationalCompare ( RationalTypeFactory :: fromFloat ( $ a -> asFloatType ( ) ) , RationalTypeFactory :: fromFloat ( $ b -> asFloatType ( ) ) ) ; }
Compare int and float types
4,438
protected function rationalCompare ( RationalType $ a , RationalType $ b ) { $ res = $ this -> calculator -> rationalSub ( $ a , $ b ) ; if ( $ res -> numerator ( ) -> get ( ) == 0 ) { return 0 ; } if ( $ res -> numerator ( ) -> get ( ) < 0 ) { return - 1 ; } return 1 ; }
Compare two rationals
4,439
protected function complexCompare ( ComplexType $ a , ComplexType $ b ) { if ( $ a -> isReal ( ) && $ b -> isReal ( ) ) { return $ this -> rationalCompare ( $ a -> r ( ) , $ b -> r ( ) ) ; } $ am = $ a -> modulus ( ) -> asFloatType ( ) -> get ( ) ; $ bm = $ b -> modulus ( ) -> asFloatType ( ) -> get ( ) ; if ( $ am == ...
Compare complex numbers . If both operands are real then compare the real parts else compare the modulii of the two numbers
4,440
public function applyConclusiveMatch ( $ userAgent ) { if ( WURFL_Configuration_ConfigHolder :: getWURFLConfig ( ) -> isHighPerformance ( ) ) { $ tolerance = WURFL_Handlers_Utils :: firstCloseParen ( $ userAgent ) ; return $ this -> getDeviceIDFromRIS ( $ userAgent , $ tolerance ) ; } else { return $ this -> getDeviceI...
If UA starts with Mozilla apply LD with tolerance 5 .
4,441
public function listCollections ( array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> getAll ( ) ; $ this -> checkResponse ( $ rs ) ; $ colls = array_get ( $ rs , 'Document...
List all collections in a Database .
4,442
public function getCollection ( $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> get ( $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] )...
Retrieves a collection information .
4,443
public function replaceCollection ( array $ data , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> replace ( $ data , $ id ) ; $ this -> checkResponse ( $ rs ) ;...
Replaces a collection .
4,444
public function listDocuments ( $ collection , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> getAll ( ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ ...
List all documents in a collection .
4,445
public function getDocument ( $ collection , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> get ( $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( ...
Retrieves a document .
4,446
public function createDocument ( $ collection , array $ data , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> create ( $ data ) ; $ this -> checkResponse ( $...
Creates a document .
4,447
public function replaceDocument ( $ collection , array $ data , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> replace ( $ data , $ id ) ; $ this -> c...
Replaces a document .
4,448
public function queryDocument ( $ collection , $ sql , array $ params = [ ] , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> query ( $ sql , $ params ) ; $ t...
Queries a collection for documents .
4,449
protected function checkResponse ( array $ response ) { $ responseCode = intval ( array_get ( $ response , '_curl_info.http_code' ) ) ; $ message = array_get ( $ response , 'message' ) ; if ( $ responseCode >= 400 ) { $ context = [ 'response_headers' => array_get ( $ response , '_curl_info.response_headers' ) ] ; throw...
Checks response status code for exceptions .
4,450
public function createQuery ( $ context = 'list' ) { $ query = parent :: createQuery ( $ context ) ; $ query -> leftJoin ( $ query -> getRootAlias ( ) . '.article' , 'article' ) -> addSelect ( 'article' ) -> leftJoin ( $ query -> getRootAlias ( ) . '.parent' , 'parent' ) -> addSelect ( 'parent' ) -> leftJoin ( $ query ...
Need to override createQuery method because of list order & joins
4,451
private static function mb_fill_string ( string $ pattern , $ length , $ encoding = 'UTF-8' ) : string { $ pattern_length = mb_strlen ( $ pattern , $ encoding ) ; $ str = '' ; $ i = 0 ; while ( $ i < $ length ) { if ( $ length - $ i >= $ pattern_length ) { $ str .= $ pattern ; $ i += $ pattern_length ; } else { $ str ....
Returns a string of given length filled with some pattern substring
4,452
public function resolve ( Request $ request , Response $ response , UriPath $ uriPath ) { $ routeName = $ uriPath -> remaining ( 'index.html' ) ; if ( ! file_exists ( $ this -> routePath . $ routeName ) ) { return $ response -> notFound ( ) ; } return $ this -> modifyContent ( $ request , $ response , file_get_contents...
processes the request
4,453
public function __isset ( $ property ) { if ( $ propertyReflector = $ this -> liberatorPropertyReflector ( $ property ) ) { return null !== $ propertyReflector -> getValue ( $ this -> popsValue ( ) ) ; } return parent :: __isset ( $ property ) ; }
Returns true if the property exists on the wrapped object .
4,454
protected function initService ( string $ type , string $ alias , array $ options ) { $ id = $ this -> resolverFactory -> resolve ( $ type , $ alias ) ; $ service = $ this -> get ( $ id ) ; $ service -> setOptions ( $ options ) ; return $ service ; }
Initializes a service by its type
4,455
public function getBid ( $ itemId ) { $ item = Item :: findOrFail ( $ itemId ) ; if ( ! $ item -> auction ) { return redirect ( $ item -> url ) -> withErrors ( [ 'This item is not an auction, so cannot be bid on.' , ] ) ; } $ bids = $ item -> getBidHistory ( ) ; $ highest_bid = $ bids -> first ( ) ? : new Bid ( ) ; if ...
Return the item bid view .
4,456
public function generate ( $ lenght = 4 , $ separator = ' ' ) { $ length = count ( $ this -> lists ) ; $ words = [ ] ; $ randomArray = static :: getRandomArray ( $ lenght ) ; foreach ( $ randomArray as $ index => $ random ) { $ list = $ this -> lists [ $ index % $ length ] ; $ words [ ] = $ list -> get ( $ random ) ; }...
Generate password from word lists .
4,457
public static function generateRu ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ Ru ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates Russian phrase password .
4,458
public static function generateEn ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ En ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates English phrase password .
4,459
public static function generateDe ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ De ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates German phrase password .
4,460
public static function generateRuTranslit ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ RuTranslit ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates transliterated Russian phrase password
4,461
protected static function getRandomArray ( $ length ) { $ bytes = random_bytes ( $ length * 2 ) ; $ result = [ ] ; foreach ( unpack ( 'S*' , $ bytes ) as $ long ) { $ result [ ] = $ long / 0xFFFF ; } return $ result ; }
Get array of random numbers between 0 . 0 - 1 . 0 .
4,462
public static function extIs ( $ value ) { if ( static :: is ( $ value ) ) { return true ; } if ( is_string ( $ value ) ) { $ value = strtolower ( $ value ) ; return ( static :: isTrueStrExt ( $ value ) || static :: isFalseStrExt ( $ value ) ) ; } return false ; }
Tests if the given value is a bool or not .
4,463
public static function compare ( $ bool1 , $ bool2 ) { if ( ! static :: is ( $ bool1 ) || ! static :: is ( $ bool2 ) ) { throw new \ InvalidArgumentException ( "The \$bool1 and \$bool2 parameters must be of type bool." ) ; } return ( ( int ) $ bool1 - ( int ) $ bool2 ) ; }
Compares two bool values .
4,464
public function add ( $ property ) { if ( ! $ property instanceof PropertyInterface ) { throw new \ InvalidArgumentException ( 'This Property must be a instance of \ClassGeneration\PropertyInterface' ) ; } if ( $ property -> getName ( ) === null ) { $ property -> setName ( 'property' . ( $ this -> count ( ) + 1 ) ) ; }...
Adds a new Property on the collection .
4,465
public function toString ( ) { $ string = '' ; $ properties = $ this -> getIterator ( ) ; foreach ( $ properties as $ property ) { $ string .= $ property -> toString ( ) ; } return $ string ; }
Parse the Property Collection to string .
4,466
public function getByName ( $ propertyName ) { $ foundList = new self ( ) ; $ list = $ this -> getIterator ( ) ; foreach ( $ list as $ property ) { if ( ( is_array ( $ propertyName ) && in_array ( $ property -> getName ( ) , $ propertyName ) ) || ( $ property -> getName ( ) === $ propertyName ) ) { $ foundList -> add (...
Find the properties by name .
4,467
protected function fillForm ( Element \ NodeElement $ form ) { $ inputs = $ form -> findAll ( 'css' , 'input[type="text"]' ) ; foreach ( $ inputs as $ i ) { if ( $ i -> isVisible ( ) ) { if ( $ i -> hasAttribute ( 'name' ) ) { $ name = $ i -> getAttribute ( 'name' ) ; $ value = $ this -> getFakerValue ( $ name ) ; } el...
Fuzz fill all form fields with random data
4,468
public function getBasicFunctionRenames ( $ maxVersion = '' ) { $ data = array ( '1.7' => array ( 'elgg_validate_action_url' => 'elgg_add_action_tokens_to_url' , 'menu_item' => 'make_register_object' , 'extend_view' => 'elgg_extend_view' , 'get_views' => 'elgg_get_views' , ) , '1.8' => array ( 'register_elgg_event_hand...
Just basic function renames from A to B
4,469
public function createToken ( string $ tokenSalt ) : Token { $ this -> setToken ( Token :: create ( $ this , $ tokenSalt ) ) ; return $ this -> token ( ) ; }
creates new token for the user with given token salt
4,470
public function bindFetcher ( $ fetcherKey , $ relationshipName , $ callback = null ) { if ( $ callback !== null ) { $ this -> fetcherRelationships [ $ fetcherKey ] [ ] = $ relationshipName ; } $ callback = $ callback ? : $ relationshipName ; $ this -> fetchers [ $ fetcherKey ] = $ callback ; }
Adds the callback to fetch a resolved relationship for a parameter on a resolver .
4,471
protected function buildParametersForResolver ( $ resolver , array $ parents , array $ defaultParameters ) { $ reflector = $ this -> getCallReflector ( $ resolver ) ; $ parameters = $ reflector -> getParameters ( ) ; $ defaultParameters = array_reverse ( $ defaultParameters ) ; return array_map ( function ( \ Reflectio...
Build the parameters needed for the function given
4,472
protected function findParent ( \ ReflectionClass $ class , $ parents ) { $ parents = array_reverse ( $ parents ) ; foreach ( array_reverse ( $ parents ) as $ parent ) { if ( $ class -> getName ( ) === get_class ( $ parent ) ) { return $ parent ; } } foreach ( array_reverse ( $ parents ) as $ parent ) { if ( $ class ->...
Try to find a parent that matches the class
4,473
private function getResolverForType ( $ type ) { $ resolver = Arr :: get ( $ this -> resolvers , $ type ) ; if ( $ resolver !== null ) { return $ resolver ; } $ parts = explode ( '.' , $ type ) ; if ( count ( $ parts ) > 1 ) { array_shift ( $ parts ) ; return $ this -> getResolverForType ( implode ( '.' , $ parts ) ) ;...
Find the resolver for the type given
4,474
protected function callResolver ( $ resolver , $ parameters ) { if ( is_string ( $ resolver ) ) { return call_user_func_array ( $ resolver , $ parameters ) ; } if ( count ( $ parameters ) === 0 ) { return $ resolver ( ) ; } if ( count ( $ parameters ) === 1 ) { return $ resolver ( $ parameters [ 0 ] ) ; } if ( count ( ...
Call the resolver with the given parameters .
4,475
protected function recordFetchedRelationship ( RelationshipResource $ relationship ) { $ this -> fetchedRelationships [ ] = $ this -> resource [ 'type' ] . '.' . $ relationship -> getName ( ) . '.' . $ relationship -> getType ( ) ; }
Save that a resource has been fetched .
4,476
public function set ( $ key , $ value ) { $ this -> loadIfNeeded ( ) ; $ this -> array [ $ key ] = $ value ; $ this -> saver -> save ( $ this -> fileName , $ this -> array , $ this -> fileMap ) ; }
Set a given configuration value and save file
4,477
public function setAll ( $ array ) { $ this -> array = $ array ; $ this -> fileMap = null ; $ this -> saver -> save ( $ this -> fileName , $ this -> array , $ this -> fileMap ) ; }
Change all configuration values and save file
4,478
public function toString ( ) { $ arguments = $ this -> getIterator ( ) ; $ params = array ( ) ; $ optionals = array ( ) ; foreach ( $ arguments as $ argument ) { if ( $ argument -> isOptional ( ) ) { $ optionals [ ] = $ argument -> toString ( ) ; } else { $ params [ ] = $ argument -> toString ( ) ; } } return implode (...
Returns the arguments in string .
4,479
public function getCapability ( $ capabilityName ) { if ( isset ( $ this -> _device -> capabilities [ $ capabilityName ] ) ) { return $ this -> _device -> capabilities [ $ capabilityName ] ; } $ key = $ this -> _device -> id . "_" . $ capabilityName ; $ capabilityValue = $ this -> _cacheProvider -> get ( $ key ) ; if (...
Returns the value of a given capability name
4,480
public function getAll ( $ service , $ page = 1 , $ perPage = 25 ) { $ params = array ( 'page' => $ page , 'per_page' => $ perPage ) ; return $ this -> _user -> get ( 'account/identity/limit/' . $ service , $ params ) ; }
Get all the limits for a service
4,481
public function create ( $ identity , $ service , $ total_allowance = false , $ analyze_queries = false ) { $ params = array ( 'service' => $ service , ) ; if ( $ total_allowance ) { $ params [ 'total_allowance' ] = $ total_allowance ; } if ( $ analyze_queries ) { $ params [ 'analyze_queries' ] = $ analyze_queries ; } ...
Create a limit for a service
4,482
public function update ( $ identity , $ service , $ total_allowance = false , $ analyze_queries = false ) { $ params = array ( ) ; if ( $ total_allowance ) { $ params [ 'total_allowance' ] = $ total_allowance ; } if ( $ analyze_queries ) { $ params [ 'analyze_queries' ] = $ analyze_queries ; } return $ response = $ thi...
Update the limit for an service
4,483
public function getAll ( $ label = null , $ page = 1 , $ perPage = 25 ) { $ params = array ( 'page' => $ page , 'per_page' => $ perPage ) ; if ( $ label !== null ) { $ params [ 'label' ] = $ label ; } return $ this -> _user -> get ( 'account/identity' , $ params ) ; }
Gets all the identities
4,484
public function create ( $ label , $ master = false , $ status = 'active' ) { $ params = array ( 'label' => $ label , 'master' => $ master , 'status' => $ status ) ; return $ this -> _user -> post ( 'account/identity' , $ params ) ; }
Creates an identity
4,485
public function update ( $ identity , $ label = null , $ master = null , $ status = null ) { $ params = array ( ) ; if ( ! is_null ( $ label ) ) { $ params [ 'label' ] = $ label ; } if ( ! is_null ( $ master ) ) { $ params [ 'master' ] = $ master ; } if ( ! is_null ( $ status ) ) { $ params [ 'status' ] = $ status ; } ...
Updates an identity
4,486
public static function createFromProperty ( PropertyInterface $ property ) { $ argument = new self ( ) ; $ argument -> setName ( $ property -> getName ( ) ) -> setType ( $ property -> getType ( ) ) ; return $ argument ; }
Creates Argument from Property Object .
4,487
protected function getCssContent ( ) { $ styleString = "" ; if ( class_exists ( "\\DOMDocument" ) ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadHTML ( $ this -> getHtmlContent ( ) ) ; foreach ( $ doc -> getElementsByTagName ( 'style' ) as $ styleNode ) { $ styleString .= $ styleNode -> nodeValue . "\r\n" ; } } else ...
Gets the CSS content extracted from the HTML source content .
4,488
function create_hash ( $ password ) { $ encrypt_method = "AES-256-CBC" ; $ key = hash ( 'sha256' , $ secret_key ) ; $ iv = substr ( hash ( 'sha256' , $ secret_iv ) , 0 , 16 ) ; $ salt = base64_encode ( openssl_encrypt ( $ string , $ encrypt_method , $ key , 0 , $ iv ) ) ; return PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITE...
These constants may be changed without breaking existing hashes .
4,489
public static function addProducer ( Producer $ producer ) { $ appId = $ producer -> getAppId ( ) ; if ( array_key_exists ( $ appId , static :: $ producers ) ) { throw new Exception \ FacadeException ( "Producer with {$appId} already exists!" ) ; } static :: $ producers [ $ appId ] = $ producer ; return true ; }
Add producer to facade
4,490
public static function addBuilder ( $ appId , $ builderFunction ) { if ( array_key_exists ( $ appId , static :: $ builders ) ) { throw new Exception \ FacadeException ( "Builder with {$appId} already exists!" ) ; } if ( ! is_callable ( $ builderFunction ) ) { throw new Exception \ FacadeException ( "Builder function fo...
Add Builder to facade builder scope
4,491
public static function getProducer ( $ appId = Producer :: DEFAULT_APP_ID ) { if ( null === $ appId ) { $ appId = Producer :: DEFAULT_APP_ID ; } if ( ! array_key_exists ( $ appId , static :: $ producers ) ) { if ( array_key_exists ( $ appId , static :: $ builders ) ) { $ func = static :: $ builders [ $ appId ] ; static...
Get producer by id
4,492
public static function getProducersStats ( ) { $ producersStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ producersStats [ $ appId ] = $ producer -> getStats ( ) ; } return $ producersStats ; }
Get producer statistic
4,493
public static function getQueuesStats ( ) { $ queuesStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ queuesStats [ $ appId ] = $ producer -> getQueue ( ) -> getStats ( ) ; } return $ queuesStats ; }
Get queues statistic
4,494
public static function getJobsReserved ( ) { $ jobsReserved = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ jobsReserved [ $ appId ] = $ producer -> getQueue ( ) -> getJobReserved ( ) ; } return $ jobsReserved ; }
Get all reserved jobs
4,495
public static function getManagersStats ( ) { $ managersStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ redis = $ producer -> getRedis ( ) ; $ keys = [ 'stat' => $ redis -> keys ( Manager :: REDIS_NS_STATS . '*' ) , 'live' => $ redis -> keys ( Manager :: REDIS_NS_LIVE . '*' ) ] ; foreach ( ...
Get all managers statistic
4,496
public function link ( Form \ Element \ Link $ element ) { $ html = '<label>' . $ element -> getLabel ( ) . '</label>' ; $ html .= '<p>' . html ( 'a' , [ 'href' => $ element -> getValue ( ) , 'target' => '_blank' ] , $ element -> getValue ( ) ) . '</p>' ; $ class = Style :: FORM_GROUP_CLASS ; $ html = html ( 'div' , co...
Render a link element
4,497
public function date ( Form \ Element \ Date $ element ) { if ( $ hasError = ! $ element -> getValidator ( ) -> isValid ( ) ) { $ element -> removeAttribute ( 'data-trigger' ) ; if ( empty ( $ element -> getAttribute ( 'data-placement' ) ) ) { $ element -> addAttribute ( 'data-placement' , 'bottom' ) ; } $ message = ''...
Render a date element
4,498
public static function getDayTimestamp ( $ now = null , $ offset = 8 ) { $ now = $ now === null ? time ( ) : $ now ; $ gtm0 = $ now - ( $ now % 86400 ) ; $ dayline = ( $ now - $ gtm0 ) / 3600 ; if ( $ dayline + $ offset > 23 ) { return $ gtm0 + 86400 + $ offset * 3600 * - 1 ; } else { return $ gtm0 + $ offset * 3600 * ...
get the timestamp at current dat start
4,499
public static function getHourTimestamp ( $ now = null ) { $ now = $ now === null ? time ( ) : $ now ; $ diff = $ now % 3600 ; return $ now - $ diff ; }
get the timestamp at current hour start