idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
18,400
public function getAttributes ( ) { $ attributes = parent :: getAttributes ( ) ; $ attributes [ 'data-schema' ] = json_encode ( $ this -> getSchemaData ( ) ) ; $ attributes [ 'data-state' ] = json_encode ( $ this -> getSchemaState ( ) ) ; return $ attributes ; }
When not used in a React form factory context this adds the schema and state data to SilverStripe template rendered attributes lists
18,401
public function getSchemaDataDefaults ( ) { $ schema = parent :: getSchemaDataDefaults ( ) ; $ schema [ 'data' ] = array_merge ( $ schema [ 'data' ] , [ 'showLinkText' => $ this -> getShowLinkText ( ) , 'linkedPage' => $ this -> getLinkPage ( ) ? $ this -> getLinkPage ( ) -> toMap ( ) : [ ] , 'title' => $ this -> Title...
Add some extra props for the React component to work with
18,402
protected function configuration ( ) { $ this -> options = array_merge ( [ 'accept' => 'image/*' ] , $ this -> options ) ; $ croppedDataInput = $ this -> croppedDataAttribute ; if ( $ this -> hasModel ( ) ) { $ croppedDataInput = Html :: getInputName ( $ this -> model , $ croppedDataInput ) ; } else { $ croppedDataInpu...
Configuration the widget .
18,403
protected function findMail ( $ type , $ value ) { $ criterias = array ( $ type => $ value ) ; $ message = $ this -> getMailCatcherClient ( ) -> searchOne ( $ criterias ) ; if ( null === $ message ) { throw new \ InvalidArgumentException ( sprintf ( 'Unable to find a message with criterias "%s".' , json_encode ( $ crit...
This method is duplicated from MailCatcherTrait for support in PHP 5 . 3
18,404
public function searchOne ( array $ criterias = array ( ) ) { $ results = $ this -> search ( $ criterias , 1 ) ; if ( count ( $ results ) !== 1 ) { return null ; } return $ results [ 0 ] ; }
Searches for one messages on the server .
18,405
public function search ( array $ criterias = array ( ) , $ limit = null ) { $ messages = array ( ) ; foreach ( $ this -> request ( 'GET' ) as $ message ) { if ( isset ( $ this -> messages [ $ message [ 'id' ] ] ) ) { $ messages [ ] = $ this -> messages [ $ message [ 'id' ] ] ; } else { $ messages [ ] = $ this -> messag...
Searches for messages on the server .
18,406
public function request ( $ method , $ path = null , $ parameters = array ( ) ) { if ( null === $ path ) { $ url = '/messages' ; } else { $ url = '/messages/' . $ path ; } return json_decode ( $ this -> requestRaw ( $ method , $ url , $ parameters ) , true ) ; }
Request the API of MailCatcher .
18,407
public function requestRaw ( $ method , $ url , $ parameters = array ( ) ) { $ url = $ this -> url . $ url ; if ( false === $ curl = curl_init ( ) ) { throw new \ RuntimeException ( 'Unable to create a new cURL handle' ) ; } $ options = array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADER => false , CURLOPT_CUSTOMRE...
Raw method to request the API of MailCatcher .
18,408
public function loadFromArray ( array $ array ) { if ( isset ( $ array [ 'filename' ] ) ) { $ this -> filename = $ array [ 'filename' ] ; } if ( isset ( $ array [ 'size' ] ) ) { $ this -> size = $ array [ 'size' ] ; } if ( isset ( $ array [ 'type' ] ) ) { $ this -> type = $ array [ 'type' ] ; } if ( isset ( $ array [ '...
Loads data into the Attachment from an array .
18,409
public function getContent ( ) { if ( null === $ this -> content ) { $ this -> content = $ this -> client -> requestRaw ( 'GET' , $ this -> href ) ; } return $ this -> content ; }
Returns content raw format .
18,410
public function loadSource ( $ source ) { $ parser = new Parser ( ) ; list ( $ this -> headers , $ this -> content ) = $ parser -> parsePart ( $ source ) ; }
Load source part .
18,411
public function register ( ) { $ pest = new Pest ( "http://" . $ this -> bridge . "/api" ) ; $ data = json_encode ( array ( 'devicetype' => 'phpHue' ) ) ; $ result = $ pest -> post ( '' , $ data ) ; return $ result ; }
Registers with a Hue hub
18,412
public function lightIds ( ) { $ result = json_decode ( $ this -> pest ( ) -> get ( 'lights' ) , true ) ; $ targets = array_keys ( $ result ) ; return $ targets ; }
Returns an array of the light numbers in the system
18,413
public function predefinedColors ( $ colorname ) { $ command = array ( ) ; switch ( $ colorname ) { case "green" : $ command [ 'hue' ] = 182 * 140 ; $ command [ 'sat' ] = 254 ; $ command [ 'bri' ] = 254 ; break ; case "red" : $ command [ 'hue' ] = 0 ; $ command [ 'sat' ] = 254 ; $ command [ 'bri' ] = 254 ; break ; case...
Build a few color commands based on color names
18,414
public function setAlert ( $ type = 'select' ) { $ data = json_encode ( array ( "alert" => $ type ) ) ; $ this -> parent -> pest ( ) -> put ( "lights/" . $ this -> id . "/state" , $ data ) ; $ this -> parent -> update ( $ this -> id ) ; }
Sets the alert state . select blinks once lselect blinks repeatedly none turns off blinking
18,415
public function setLight ( $ input ) { $ data = json_encode ( $ input ) ; $ this -> parent -> pest ( ) -> put ( "lights/" . $ this -> id . "/state" , $ data ) ; $ this -> parent -> update ( $ this -> id ) ; }
Sets the state property
18,416
private function _setString ( $ key , $ val ) { $ this -> _result = str_replace ( '{{' . $ key . '}}' , $ val , $ this -> _result ) ; }
Template string manipulation
18,417
private function _setArray ( $ key , $ val ) { preg_match ( "/<loop\." . $ key . ">(.*?)<\/loop\." . $ key . ">/s" , $ this -> _result , $ l ) ; $ loop_content = '' ; $ loop = $ l [ 1 ] ; foreach ( $ val as $ v ) { $ loop_replaced = $ loop ; foreach ( $ v as $ x => $ y ) { $ loop_replaced = str_replace ( '{{' . $ key ....
Template loop manipulation
18,418
private function _setBool ( $ key , $ val ) { if ( $ key && ! $ val ) { $ this -> _result = preg_replace ( "/<if\." . $ key . ">(.*?)<\/if\." . $ key . ">/s" , '' , $ this -> _result ) ; } $ this -> _result = str_replace ( "<if." . $ key . ">" , '' , $ this -> _result ) ; $ this -> _result = str_replace ( "</if." . $ k...
Template boolean manipulation
18,419
private function _setContentFromFile ( ) { $ this -> setContent ( '' ) ; if ( $ filename = $ this -> getTemplate ( ) ) { if ( file_exists ( $ filename ) ) { $ content = trim ( file_get_contents ( $ this -> _filename ) ) ; $ this -> setContent ( $ content ) ; } } }
Set content from file
18,420
public function getCurrentStep ( ) { $ startStepClass = $ this -> config ( ) -> get ( 'start_step' ) ; if ( ! isset ( $ startStepClass ) ) { user_error ( 'MultiForm::init(): Please define a $start_step on ' . static :: class , E_USER_ERROR ) ; } $ currentStep = null ; $ StepID = $ this -> controller -> getRequest ( ) -...
Get the current step .
18,421
protected function setCurrentStep ( $ step ) { $ this -> session -> CurrentStepID = $ step -> ID ; $ step -> setForm ( $ this ) ; return $ this -> session -> write ( ) ; }
Set the step passed in as the current step .
18,422
protected function setSession ( ) { $ this -> session = $ this -> getCurrentSession ( ) ; if ( ! $ this -> session ) { $ session = MultiFormSession :: create ( ) ; $ session -> write ( ) ; $ this -> session = $ session ; } }
Set up the session .
18,423
public function actionsFor ( $ step ) { $ actions = FieldList :: create ( ) ; if ( $ step -> isFinalStep ( ) ) { $ actions -> push ( FormAction :: create ( 'finish' , $ step -> getSubmitText ( ) ) ) ; } else { $ actions -> push ( FormAction :: create ( 'next' , $ step -> getNextText ( ) ) ) ; } if ( $ step -> getPrevio...
Build a FieldList of the FormAction fields for the given step .
18,424
public function next ( $ data , $ form ) { $ this -> save ( $ form -> getData ( ) ) ; $ nextStepClass = $ this -> getCurrentStep ( ) -> getNextStep ( ) ; if ( ! $ nextStepClass ) { $ this -> controller -> redirectBack ( ) ; return false ; } if ( ! $ this -> getCurrentStep ( ) -> validateStep ( $ data , $ form ) ) { $ t...
Determine what to do when the next action is called .
18,425
public function prev ( $ data , $ form ) { $ this -> save ( $ form -> getData ( ) ) ; $ prevStepClass = $ this -> getCurrentStep ( ) -> getPreviousStep ( ) ; if ( ! $ prevStepClass && ! $ this -> getCurrentStep ( ) -> canGoBack ( ) ) { $ this -> controller -> redirectBack ( ) ; return false ; } $ prevStep = DataObject ...
Determine what to do when the previous action is called .
18,426
protected function save ( $ data ) { $ currentStep = $ this -> getCurrentStep ( ) ; if ( is_array ( $ data ) ) { foreach ( $ data as $ field => $ value ) { if ( in_array ( $ field , $ this -> config ( ) -> get ( 'ignored_fields' ) ) ) { unset ( $ data [ $ field ] ) ; } } $ currentStep -> saveData ( $ data ) ; } return ...
Save the raw data given back from the form into session .
18,427
public function run ( $ request ) { $ sessions = $ this -> getExpiredSessions ( ) ; $ delCount = 0 ; if ( $ sessions ) { foreach ( $ sessions as $ session ) { $ session -> delete ( ) ; $ delCount ++ ; } } echo $ delCount . ' session records deleted that were older than ' . $ this -> config ( ) -> get ( 'session_expiry_...
Run this cron task .
18,428
public function augmentSQL ( SQLSelect $ query , DataQuery $ dataQuery = null ) { $ where = $ query -> getWhere ( ) ; if ( ! $ where && ! $ this -> wantsTemporary ( $ query ) ) { $ from = array_values ( $ query -> getFrom ( ) ) ; $ query -> addWhere ( "{$from[0]}.\"MultiFormIsTemporary\" = '0'" ) ; return ; } $ filterK...
Augment any queries to MultiFormObjectDecorator and only return anything that isn t considered temporary .
18,429
protected function wantsTemporary ( $ query ) { foreach ( $ query -> getWhere ( ) as $ whereClause ) { $ from = array_values ( $ query -> getFrom ( ) ) ; $ key = key ( $ whereClause ) ; if ( $ key == "{$from[0]}.\"MultiFormIsTemporary\" = ?" && current ( $ whereClause [ $ key ] ) == 1 ) { return true ; } } return false...
Determines if the current query is supposed to be exempt from the automatic filtering out of temporary records .
18,430
public function getNextStepFromDatabase ( ) { if ( $ this -> SessionID && is_numeric ( $ this -> SessionID ) ) { $ nextSteps = $ this -> config ( ) -> get ( 'next_steps' ) ; if ( is_string ( $ nextSteps ) ) { return DataObject :: get_one ( $ nextSteps , "\"SessionID\" = {$this->SessionID}" ) ; } elseif ( is_array ( $ n...
Returns the next step to the current step in the database .
18,431
public function getPreviousStep ( ) { $ steps = MultiFormStep :: get ( ) -> filter ( 'SessionID' , $ this -> SessionID ) -> sort ( 'LastEdited' , 'DESC' ) ; if ( $ steps ) { foreach ( $ steps as $ step ) { $ step -> setForm ( $ this -> form ) ; if ( $ step -> getNextStep ( ) ) { if ( $ step -> getNextStep ( ) == static...
Returns the previous step if there is one .
18,432
public function getValueFromOtherStep ( $ fromStep , $ key ) { if ( ! array_key_exists ( 'steps_' . $ fromStep , $ this -> step_data_cache ) ) { $ steps = self :: get ( ) -> filter ( 'SessionID' , $ this -> form -> session -> ID ) ; if ( $ steps ) { foreach ( $ steps as $ step ) { $ this -> step_data_cache [ 'steps_' ....
Returns the submitted value if any of any steps .
18,433
public function copyValueFromOtherStep ( FieldList $ fields , $ formStep , $ fieldName , $ fieldNameTarget = null ) { if ( ! $ fieldNameTarget ) { $ fieldNameTarget = $ fieldName ; } $ fields -> fieldByName ( $ fieldNameTarget ) -> setValue ( $ this -> getValueFromOtherStep ( $ formStep , $ fieldName ) ) ; }
allows to get a value from another step copied over
18,434
public function add ( array $ updates , $ class , $ append = true ) { $ commandClass = $ this -> getCommandClass ( 'update.add' ) ; $ this -> command = new $ commandClass ( $ updates , $ class , $ append ) ; return $ this -> command ; }
Adds a relation in a link - list|set .
18,435
public function alter ( $ class , $ attribute , $ value ) { $ commandClass = $ this -> getCommandClass ( 'class.alter' ) ; $ this -> command = new $ commandClass ( $ class , $ attribute , $ value ) ; return $ this -> command ; }
Alters an attribute of a class .
18,436
public function between ( $ key , $ left , $ right ) { return $ this -> command -> between ( $ key , $ left , $ right ) ; }
Converts a normal select into an index one . You use do a select on an index you can use the between operator .
18,437
public function index ( $ property , $ type , $ class = null ) { $ commandClass = $ this -> getCommandClass ( 'index.create' ) ; $ this -> command = new $ commandClass ( $ property , $ type , $ class ) ; return $ this -> command ; }
Creates a index
18,438
public function remove ( array $ updates , $ class , $ append = true ) { $ commandClass = $ this -> getCommandClass ( 'update.remove' ) ; $ this -> command = new $ commandClass ( $ updates , $ class , $ append ) ; return $ this -> command ; }
Removes a link from a link - set|list .
18,439
public function truncate ( $ entity , $ andCluster = false ) { try { $ validator = new RidValidator ; $ validator -> check ( $ entity ) ; $ commandClass = $ this -> getCommandClass ( 'truncate.record' ) ; } catch ( ValidationException $ e ) { $ commandClass = $ this -> getCommandClass ( 'truncate.class' ) ; if ( $ andC...
Truncates an entity .
18,440
public function unindex ( $ property , $ class = null ) { $ commandClass = $ this -> getCommandClass ( 'index.drop' ) ; $ this -> command = new $ commandClass ( $ property , $ class ) ; return $ this -> command ; }
Removes a index
18,441
public function put ( array $ values , $ class , $ append = true ) { $ commandClass = $ this -> getCommandClass ( 'update.put' ) ; $ this -> command = new $ commandClass ( $ values , $ class , $ append ) ; return $ this -> command ; }
Changes the internal command to an PUT setting the class to update and the values to be written .
18,442
protected function getCommandClass ( $ id ) { if ( isset ( $ this -> commands [ $ id ] ) ) { return $ this -> commands [ $ id ] ; } throw new Exception ( sprintf ( "command %s not found in %s" , $ id , get_called_class ( ) ) ) ; }
Returns on of the commands that belong to the query .
18,443
public function getReflectionClass ( ) { if ( ! $ this -> refClass ) { $ this -> refClass = new \ ReflectionClass ( $ this -> getName ( ) ) ; } return $ this -> refClass ; }
Gets the ReflectionClass instance for this mapped class .
18,444
public function getFieldNames ( ) { $ names = array ( ) ; foreach ( $ this -> getFields ( ) as $ field ) { $ names [ ] = $ field -> name ; } return $ names ; }
A numerically indexed list of field names of this persistent class .
18,445
public function getAssociationNames ( ) { $ names = array ( ) ; foreach ( $ this -> getAssociations ( ) as $ field ) { $ names [ ] = $ field -> name ; } return $ names ; }
A numerically indexed list of association names of this persistent class .
18,446
public function getProducts ( array $ options = [ ] ) { return $ this -> dataStore -> getResource ( CodesWholesale :: API_VERSION_V2 . '/products' , CodesWholesale :: PRODUCT_LIST , $ options ) ; }
You can filter products by using below query params as array value
18,447
public static function create ( $ parameters ) { if ( is_string ( $ parameters ) ) { return self :: fromString ( $ parameters ) ; } if ( is_array ( $ parameters ) ) { return self :: fromArray ( $ parameters ) ; } throw new InvalidArgumentException ( 'Invalid parameters type' ) ; }
Creates a new binding parameters instance from a URI string or a parameters array .
18,448
public static function fromString ( $ uri ) { $ parameters = parse_url ( $ uri ) ; if ( isset ( $ parameters [ 'user' ] ) ) { $ parameters [ 'username' ] = $ parameters [ 'user' ] ; } if ( isset ( $ parameters [ 'pass' ] ) ) { $ parameters [ 'password' ] = $ parameters [ 'pass' ] ; } if ( isset ( $ parameters [ 'path' ...
Creates a new binding parameters instance from a URI string .
18,449
public static function fromArray ( Array $ parameters ) { $ host = isset ( $ parameters [ 'host' ] ) ? $ parameters [ 'host' ] : self :: DEFAULT_HOST ; $ port = isset ( $ parameters [ 'port' ] ) ? $ parameters [ 'port' ] : self :: DEFAULT_PORT ; $ user = isset ( $ parameters [ 'username' ] ) ? $ parameters [ 'username'...
Creates a new binding parameters instance from a parameters array .
18,450
public function getClassByPath ( $ file , $ namespace ) { $ absPath = realpath ( $ file ) ; $ namespaces = explode ( '/' , $ absPath ) ; $ start = false ; $ i = 0 ; $ chunk = explode ( '\\' , $ namespace ) ; $ namespace = array_shift ( $ chunk ) ; while ( $ namespaces [ $ i ] != $ namespace ) { unset ( $ namespaces [ $...
Returns the fully qualified name of a class by its path
18,451
public function getClassAnnotation ( $ class ) { $ reflClass = new \ ReflectionClass ( $ class ) ; $ mappedDocumentClass = static :: ANNOTATION_CLASS_CLASS ; foreach ( $ this -> annotationReader -> getClassAnnotations ( $ reflClass ) as $ annotation ) { if ( $ annotation instanceof $ mappedDocumentClass ) { return $ an...
Returns the annotation of a class .
18,452
public function getTokens ( ) { preg_match_all ( "/(\:\w+)/" , $ this -> getSchema ( ) , $ matches ) ; $ tokens = array ( ) ; foreach ( $ matches [ 0 ] as $ match ) { $ tokens [ $ match ] = array ( ) ; } return $ tokens ; }
Analyzing the command s SCHEMA this method returns all the tokens allocable in the command .
18,453
public function where ( $ condition , $ value = null , $ append = false , $ clause = "WHERE" ) { if ( is_array ( $ value ) ) { $ condition = $ this -> formatWhereConditionWithMultipleTokens ( $ condition , $ value , $ this -> escapeValidator ) ; } else { if ( $ value === null ) { $ condition = preg_replace ( "/=\s*\?/"...
Adds a WHERE conditions into the current query .
18,454
public function returns ( $ returns ) { $ returnTypes = $ this -> getValidReturnTypes ( ) ; if ( count ( $ returnTypes ) <= 0 ) { throw new LogicException ( "Return clause not supported for this statement" ) ; } $ returns = strtoupper ( $ returns ) ; if ( ! in_array ( $ returns , $ returnTypes ) ) { throw new LogicExce...
Sets the Returns token
18,455
protected function checkToken ( $ token ) { if ( ! array_key_exists ( $ token , $ this -> tokens ) ) { throw new TokenNotFoundException ( $ token , get_called_class ( ) ) ; } return $ this -> tokens [ $ token ] ; }
Checks if a token is set returning it if it is .
18,456
protected function clearToken ( $ token ) { $ token = $ this -> tokenize ( $ token ) ; $ this -> checkToken ( $ token ) ; $ this -> tokens [ $ token ] = array ( ) ; }
Clears the value of a token .
18,457
protected function getTokenFormatter ( $ token ) { $ formatters = $ this -> getTokenFormatters ( ) ; if ( ! array_key_exists ( $ token , $ formatters ) ) { $ message = "The class %s does not know how to format the %s token\n" . "Have you added it in the getTokenFormatters() method?" ; throw new Exception ( sprintf ( $ ...
Returns the formatter for a particular token .
18,458
protected function getTokenReplaces ( ) { $ replaces = array ( ) ; foreach ( $ this -> tokens as $ token => $ value ) { $ key = $ this -> getFormatter ( ) -> untokenize ( $ token ) ; $ formatter = $ this -> getTokenFormatter ( $ key ) ; $ replaces [ $ token ] = $ formatter :: format ( $ value ) ; } return $ replaces ; ...
Returns the values to replace command s schema tokens .
18,459
protected function getValidStatement ( ) { $ schema = $ this -> getSchema ( ) ; $ statement = $ this -> replaceTokens ( $ schema ) ; $ statement = preg_replace ( '/( ){2,}/' , ' ' , $ statement ) ; return trim ( $ statement ) ; }
Build the command replacing schema tokens with actual values and cleaning the command synthax .
18,460
protected function replaceTokens ( $ statement ) { $ replaces = $ this -> getTokenReplaces ( ) ; return str_replace ( array_keys ( $ replaces ) , $ replaces , $ statement ) ; }
Replaces the tokens in the command s schema with their actual values in the current object .
18,461
public function setToken ( $ token , $ tokenValue , $ append = false , $ first = false ) { return $ this -> setTokenValues ( $ token , array ( $ tokenValue ) , $ append , $ first ) ; }
Sets a single value for a token
18,462
public function setPotential ( $ potential , VertexInterface $ from ) { $ potential = ( int ) $ potential ; if ( ! $ this -> getPotential ( ) || $ potential < $ this -> getPotential ( ) ) { $ this -> potential = $ potential ; $ this -> potentialFrom = $ from ; return true ; } return false ; }
Sets the potential for the vertex if the vertex has no potential or the one it has is higher than the new one .
18,463
public function hydrate ( \ stdClass $ orientObject , Proxy $ proxy = null ) { $ classProperty = static :: ORIENT_PROPERTY_CLASS ; if ( $ proxy ) { $ this -> fill ( $ proxy , $ orientObject ) ; return $ proxy ; } elseif ( property_exists ( $ orientObject , $ classProperty ) ) { $ orientClass = $ orientObject -> $ class...
Takes an Doctrine \ OrientDB JSON object and finds the class responsible to map that object . If the class is found a new POPO is instantiated and the properties inside the JSON object are filled accordingly .
18,464
public function hydrateCollection ( array $ collection ) { $ records = array ( ) ; foreach ( $ collection as $ key => $ record ) { if ( $ record instanceof \ stdClass ) { $ records [ $ key ] = $ this -> hydrate ( $ record ) ; } else { $ records [ $ key ] = $ this -> hydrateRid ( new Rid ( $ record ) ) ; } } return new ...
Hydrates an array of documents .
18,465
protected function createDocument ( $ class , \ stdClass $ orientObject ) { $ metadata = $ this -> getMetadataFactory ( ) -> getMetadataFor ( $ class ) ; if ( isset ( $ orientObject -> { '@rid' } ) ) { $ rid = new Rid ( $ orientObject -> { '@rid' } ) ; if ( $ this -> getUnitOfWork ( ) -> hasProxyFor ( $ rid ) ) { $ doc...
Either tries to get the proxy
18,466
protected function castProperty ( $ annotation , $ propertyValue ) { $ propertyId = $ this -> getCastedPropertyCacheKey ( $ annotation -> type , $ propertyValue ) ; if ( ! isset ( $ this -> castedProperties [ $ propertyId ] ) ) { $ method = 'cast' . $ this -> inflector -> camelize ( $ annotation -> type ) ; $ this -> g...
Casts a value according to how it was annotated .
18,467
protected function fill ( $ document , \ stdClass $ object ) { $ metadata = $ this -> getMetadataFactory ( ) -> getMetadataFor ( get_class ( $ document ) ) ; $ propertyAnnotations = $ this -> getMetadataFactory ( ) -> getObjectPropertyAnnotations ( $ document ) ; foreach ( $ propertyAnnotations as $ property => $ annot...
Given an object and an Orient - object it fills the former with the latter .
18,468
protected function hydrateValue ( $ value , PropertyAnnotation $ annotation ) { if ( $ annotation -> type ) { try { $ value = $ this -> castProperty ( $ annotation , $ value ) ; } catch ( \ Exception $ e ) { if ( $ annotation -> isNullable ( ) ) { $ value = null ; } else { throw $ e ; } } } return $ value ; }
Hydrates the value
18,469
public function castDecimal ( ) { $ min = ( float ) 4.9E-324 ; $ max = ( float ) 1.7976931348623157E+308 ; $ value = ( float ) $ this -> value ; if ( $ value >= $ min && $ value <= $ max ) { return $ value ; } $ castFunction = function ( $ value ) use ( $ min , $ max ) { if ( $ value < $ min ) { return $ min ; } if ( $...
Casts the internal value to an integer cmprehended between a range of accepted integers .
18,470
public function castFloat ( ) { $ castFunction = function ( $ value ) { return ( float ) $ value ; } ; if ( is_numeric ( $ this -> value ) ) { return $ castFunction ( $ this -> value ) ; } return $ this -> handleMismatch ( $ castFunction , 'double' ) ; }
Casts the value to a float .
18,471
public function castInteger ( ) { $ castFunction = function ( $ value ) { return is_object ( $ value ) ? 1 : ( int ) $ value ; } ; if ( is_numeric ( $ this -> value ) ) { return $ castFunction ( $ this -> value ) ; } return $ this -> handleMismatch ( $ castFunction , 'integer' ) ; }
Casts the value into an integer .
18,472
public function castString ( ) { $ castFunction = function ( $ value ) { return is_array ( $ value ) ? 'Array' : ( string ) $ value ; } ; if ( is_string ( $ this -> value ) ) { return $ castFunction ( $ this -> value ) ; } return $ this -> handleMismatch ( $ castFunction , 'string' ) ; }
Casts the value to string .
18,473
protected function convertJsonCollectionToArray ( ) { if ( ! is_array ( $ this -> value ) && is_object ( $ this -> value ) ) { $ orientObjects = array ( ) ; $ refClass = new \ ReflectionObject ( $ this -> value ) ; $ properties = $ refClass -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; foreach ( $ properties...
If a JSON value is converted in an object containing other objects to hydrate this method converts the main object in an array .
18,474
protected static function stripNonSQLCharactersArray ( array $ strings , $ nonFilter = null ) { return array_map ( function ( $ string ) use ( $ nonFilter ) { return Query :: stripNonSQLCharacters ( $ string , $ nonFilter ) ; } , $ strings ) ; }
Strips non - SQL charactes from the strings contained in the the array leaving intact regular characters a - z and integers .
18,475
public function identifyClass ( Rid $ rid ) { $ map = $ this -> getMap ( ) ; $ splitRid = explode ( ':' , ltrim ( $ rid -> getValue ( ) , '#' ) ) ; $ clusterId = $ splitRid [ 0 ] ; foreach ( $ map as $ class => $ clusters ) { if ( in_array ( $ clusterId , $ clusters ) ) { return $ class ; } } throw MappingException :: ...
Tries to identify the class of an rid by matching it against the clusters in the database
18,476
public function generateMap ( ) { $ map = array ( ) ; $ database = $ this -> binding -> getDatabase ( ) -> getData ( ) ; foreach ( $ database -> classes as $ class ) { $ map [ $ class -> name ] = $ class -> clusters ; } $ this -> map = $ map ; $ this -> cache -> save ( $ this -> getCacheKey ( ) , $ map ) ; }
Creates the mapping of classes to clusters it is public so it can be called forcibly which will be handy if it s done in some cache - warmup task .
18,477
protected function load ( ) { if ( $ this -> cache -> contains ( $ this -> getCacheKey ( ) ) ) { $ this -> map = $ this -> cache -> fetch ( $ this -> getCacheKey ( ) ) ; } else { $ this -> generateMap ( ) ; } }
Tries to load the map from cache otherwise generates it .
18,478
public function getCookies ( ) { $ jar = array ( ) ; $ headers = $ this -> getRawHeaders ( ) ; if ( preg_match_all ( '/Set-Cookie: (.*)\b/' , $ headers , $ cookies ) ) { foreach ( $ cookies [ 1 ] as $ cookie ) { list ( $ cookie , ) = explode ( ';' , $ cookie , 2 ) ; list ( $ name , $ value ) = explode ( '=' , $ cookie ...
Returns the cookies set in the current response .
18,479
public function getValidStatusCodes ( ) { return array ( self :: STATUS_OK , self :: STATUS_ACCEPTED , self :: STATUS_NON_AUTHORITATIVE_INFORMATION , self :: STATUS_NO_CONTENT , self :: STATUS_RESET_CONTENT , self :: STATUS_PARTIAL_CONTENT , self :: STATUS_CREATED ) ; }
Returns an array for the HTTP status codes that are considered as valid responses .
18,480
protected function buildHeaders ( $ headers ) { $ parts = explode ( "\r\n" , $ headers ) ; $ status = array_shift ( $ parts ) ; $ statusParts = explode ( ' ' , $ status ) ; if ( array_key_exists ( 0 , $ statusParts ) ) { $ this -> setProtocol ( $ statusParts [ 0 ] ) ; } if ( array_key_exists ( 1 , $ statusParts ) ) { $...
Builds headers array from a well - formatted string .
18,481
protected function getRid ( Proxy $ proxy ) { $ metadata = $ this -> getManager ( ) -> getClassMetadata ( get_parent_class ( $ proxy ) ) ; return $ metadata -> getIdentifierValues ( $ proxy ) ; }
Gets the rid of the proxy .
18,482
protected function load ( Rid $ rid , $ fetchPlan = null ) { $ results = $ this -> getHydrator ( ) -> load ( array ( $ rid -> getValue ( ) ) , $ fetchPlan ) ; if ( isset ( $ results ) && count ( $ results ) ) { $ record = is_array ( $ results ) ? array_shift ( $ results ) : $ results ; $ results = $ this -> getHydrator...
Executes a query against OrientDB to find the specified RID and finalizes the hydration result .
18,483
protected function getRequestCookies ( ) { $ pairs = array ( ) ; foreach ( $ this -> cookies as $ k => $ v ) { $ pairs [ ] = "$k=$v" ; } return join ( $ pairs , ';' ) ; }
Returns a string with the list of cookies for the Cookie header .
18,484
public function execute ( $ method , $ location ) { curl_setopt_array ( $ this -> curl , array ( CURLOPT_URL => $ location , CURLOPT_COOKIE => $ this -> getRequestCookies ( ) , CURLOPT_CUSTOMREQUEST => $ method , ) ) ; if ( ! $ response = curl_exec ( $ this -> curl ) ) { $ this -> restart ( ) ; throw new EmptyResponseE...
Executes a Curl .
18,485
public function delete ( $ location , $ body = null ) { curl_setopt ( $ this -> curl , CURLOPT_CUSTOMREQUEST , "DELETE" ) ; if ( $ body ) { curl_setopt ( $ this -> curl , CURLOPT_POSTFIELDS , $ body ) ; } return $ this -> execute ( 'DELETE' , $ location ) ; }
Executes a DELETE on a resource .
18,486
public function get ( $ location ) { curl_setopt ( $ this -> curl , CURLOPT_HTTPGET , true ) ; return $ this -> execute ( 'GET' , $ location ) ; }
GETs a resource .
18,487
public function post ( $ location , $ body ) { curl_setopt ( $ this -> curl , CURLOPT_POST , 1 ) ; curl_setopt ( $ this -> curl , CURLOPT_POSTFIELDS , $ body ) ; curl_setopt ( $ this -> curl , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' ) ) ; return $ this -> execute ( 'POST' , $ location ) ; }
Executes a POST on a location .
18,488
public function put ( $ location , $ body ) { curl_setopt ( $ this -> curl , CURLOPT_CUSTOMREQUEST , 'PUT' ) ; curl_setopt ( $ this -> curl , CURLOPT_POSTFIELDS , $ body ) ; curl_setopt ( $ this -> curl , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' ) ) ; return $ this -> execute ( 'PUT' , $ location )...
PUTs a resource .
18,489
public function setAuthentication ( $ credentials ) { $ this -> authentication = $ credentials ; curl_setopt ( $ this -> curl , CURLOPT_USERPWD , $ credentials ) ; }
Sets the authentication string for the next HTTP requests .
18,490
public function restart ( ) { curl_close ( $ this -> curl ) ; $ this -> cookies = array ( ) ; $ this -> curl = $ this -> createCurlHandle ( ) ; }
Reinitializes the client for a completely new session .
18,491
protected function createCurlHandle ( ) { $ options = $ this -> getDefaultCurlOptions ( ) ; if ( isset ( $ this -> authentication ) ) { $ options [ CURLOPT_USERPWD ] = $ this -> authentication ; } $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , $ options ) ; return $ curl ; }
Creates and initializes the underlying cURL handle .
18,492
private static function encryptRSAESOAEP ( RSAKey $ key , string $ m , Hash $ hash ) : string { $ mLen = \ mb_strlen ( $ m , '8bit' ) ; $ lHash = $ hash -> hash ( '' ) ; $ ps = \ str_repeat ( \ chr ( 0 ) , $ key -> getModulusLength ( ) - $ mLen - 2 * $ hash -> getLength ( ) - 2 ) ; $ db = $ lHash . $ ps . \ chr ( 1 ) ....
RSAES - OAEP - ENCRYPT .
18,493
public function setOptiPng ( \ PHPImageOptim \ Tools \ Png \ OptiPng $ optiPng ) { $ this -> optiPng = $ optiPng ; return $ this ; }
Set png adapter
18,494
public function setJpegOptim ( \ PHPImageOptim \ Tools \ Jpeg \ JpegOptim $ jpegOptim ) { $ this -> jpegOptim = $ jpegOptim ; return $ this ; }
Set jpeg adapter
18,495
public function setGifsicle ( \ PHPImageOptim \ Tools \ Gif \ Gifsicle $ gifsicle ) { $ this -> gifsicle = $ gifsicle ; return $ this ; }
Set gif adapter
18,496
public function getDefaultPrice ( ) { $ prices = $ this -> getPrices ( ) ; foreach ( $ prices as $ price ) { if ( $ price -> from == 1 ) { return $ price -> value ; } } }
Returns first price range s price . The one from price list .
18,497
public function getLowestPrice ( ) { $ prices = $ this -> getPrices ( ) ; $ lowest = $ prices [ 0 ] -> value ; foreach ( $ prices as $ price ) { if ( $ price -> value < $ lowest ) { $ lowest = $ price -> value ; } } return $ lowest ; }
Returns lowest price for product .
18,498
protected function getLocation ( $ method , $ database = null , array $ arguments = null ) { $ location = "http://{$this->server}/$method" ; if ( $ database ) { $ location .= '/' . rawurlencode ( $ database ) ; } if ( $ arguments ) { $ location .= '/' . implode ( '/' , array_map ( 'rawurlencode' , $ arguments ) ) ; } r...
Creates a relative URL for the specified OrientDB method call .
18,499
protected function getQueryLocation ( $ database , $ query , $ limit = null , $ fetchPlan = null , $ language = BindingInterface :: LANGUAGE_SQLPLUS ) { $ arguments = array ( $ language , $ query ) ; if ( isset ( $ limit ) ) { $ arguments [ ] = $ limit ; } if ( isset ( $ fetchPlan ) ) { $ arguments [ ] = $ fetchPlan ; ...
Returns the URL for the execution of a query .