idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
52,100
public static function find ( ) { try { $ streamFactory = static :: findOneByType ( StreamFactory :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new NotFoundException ( 'No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message impleme...
Finds a Stream Factory .
52,101
public static function find ( ) { try { $ client = static :: findOneByType ( HttpClient :: class ) ; } catch ( DiscoveryFailedException $ e ) { throw new NotFoundException ( 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".' , 0 , ...
Finds an HTTP Client .
52,102
public function getMatchingCookies ( Cookie $ cookie ) { $ match = function ( $ matchCookie ) use ( $ cookie ) { return $ matchCookie -> match ( $ cookie ) ; } ; return $ this -> findMatchingCookies ( $ match ) ; }
Returns all matching cookies .
52,103
protected function findMatchingCookies ( callable $ match ) { $ cookies = [ ] ; foreach ( $ this -> cookies as $ cookie ) { if ( $ match ( $ cookie ) ) { $ cookies [ ] = $ cookie ; } } return $ cookies ; }
Finds matching cookies based on a callable .
52,104
public function removeMatchingCookies ( $ name = null , $ domain = null , $ path = null ) { $ match = function ( $ cookie ) use ( $ name , $ domain , $ path ) { $ match = true ; if ( isset ( $ name ) ) { $ match = $ match && ( $ cookie -> getName ( ) === $ name ) ; } if ( isset ( $ domain ) ) { $ match = $ match && $ c...
Removes cookies which match the given parameters .
52,105
public static function createWithoutValidation ( $ name , $ value = null , $ maxAge = null , $ domain = null , $ path = null , $ secure = false , $ httpOnly = false , \ DateTime $ expires = null ) { $ cookie = new self ( 'name' , null , null , $ domain , $ path , $ secure , $ httpOnly , $ expires ) ; $ cookie -> name =...
Creates a new cookie without any attribute validation .
52,106
public function matchPath ( $ path ) { return $ this -> path === $ path || ( 0 === strpos ( $ path , rtrim ( $ this -> path , '/' ) . '/' ) ) ; }
Checks whether this cookie is meant for this path .
52,107
public function isValid ( ) { try { $ this -> validateName ( $ this -> name ) ; $ this -> validateValue ( $ this -> value ) ; $ this -> validateMaxAge ( $ this -> maxAge ) ; } catch ( \ InvalidArgumentException $ e ) { return false ; } return true ; }
Validates cookie attributes .
52,108
private function validateName ( $ name ) { if ( strlen ( $ name ) < 1 ) { throw new \ InvalidArgumentException ( 'The name cannot be empty' ) ; } if ( preg_match ( '/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/' , $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The cookie name "%s" con...
Validates the name attribute .
52,109
private function normalizePath ( $ path ) { $ path = rtrim ( $ path , '/' ) ; if ( empty ( $ path ) or '/' !== substr ( $ path , 0 , 1 ) ) { $ path = '/' ; } return $ path ; }
Processes path as per spec in RFC 6265 .
52,110
public function setHeadersFromArray ( array $ headers ) { $ status = array_shift ( $ headers ) ; $ this -> setStatus ( $ status ) ; foreach ( $ headers as $ headerLine ) { $ headerLine = trim ( $ headerLine ) ; if ( '' === $ headerLine ) { continue ; } $ this -> addHeader ( $ headerLine ) ; } return $ this ; }
Add headers represented by an array of header lines .
52,111
public function setStatus ( $ statusLine ) { $ parts = explode ( ' ' , $ statusLine , 3 ) ; if ( count ( $ parts ) < 2 || 0 !== strpos ( strtolower ( $ parts [ 0 ] ) , 'http/' ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid HTTP status line' , $ statusLine ) ) ; } $ reasonPhrase = count ( $ ...
Set response status from a status string .
52,112
public function addHeader ( $ headerLine ) { $ parts = explode ( ':' , $ headerLine , 2 ) ; if ( 2 !== count ( $ parts ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" is not a valid HTTP header line' , $ headerLine ) ) ; } $ name = trim ( $ parts [ 0 ] ) ; $ value = trim ( $ parts [ 1 ] ) ; if ( $ this -> ...
Add header represented by a string .
52,113
protected function fill ( ) { $ readFilterCallback = $ this -> readFilterCallback ; $ this -> buffer .= $ readFilterCallback ( $ this -> stream -> read ( self :: BUFFER_SIZE ) ) ; if ( $ this -> stream -> eof ( ) ) { $ this -> buffer .= $ readFilterCallback ( ) ; } }
Buffer is filled by reading underlying stream .
52,114
private function addBody ( MessageInterface $ request , $ message ) { $ stream = $ request -> getBody ( ) ; if ( ! $ stream -> isSeekable ( ) || 0 === $ this -> maxBodyLength ) { return $ message . "\n" ; } if ( null === $ this -> maxBodyLength ) { $ message .= "\n" . $ stream -> __toString ( ) ; } else { $ message .= ...
Add the message body if the stream is seekable .
52,115
public static function createUrlMatcher ( Authentication $ authentication , $ url ) { $ matcher = function ( RequestInterface $ request ) use ( $ url ) { return preg_match ( $ url , $ request -> getRequestTarget ( ) ) ; } ; return new static ( $ authentication , $ matcher ) ; }
Creates a matching authentication for an URL .
52,116
public static function addColorOption ( array $ args , $ colorOption ) { if ( ! $ colorOption || in_array ( $ colorOption , $ args ) || ! preg_match ( '/^--([a-z]+$)|(^--[a-z]+=)/' , $ colorOption , $ matches ) ) { return $ args ; } if ( isset ( $ matches [ 2 ] ) ) { if ( false !== ( $ index = array_search ( $ matches ...
Returns an array of parameters including a color option if required
52,117
public static function supportsColor ( $ output ) { if ( defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ) { return ( function_exists ( 'sapi_windows_vt100_support' ) && sapi_windows_vt100_support ( $ output ) ) || false !== getenv ( 'ANSICON' ) || 'ON' === getenv ( 'ConEmuANSI' ) || 'xterm' === getenv ( 'TERM' ) ; } if ( func...
Returns true if the output stream supports colors
52,118
public function check ( ) { $ this -> notify ( Status :: CHECK , $ this -> loaded ) ; $ envArgs = explode ( '|' , ( string ) getenv ( $ this -> envAllowXdebug ) ) ; if ( empty ( $ envArgs [ 0 ] ) && $ this -> requiresRestart ( ( bool ) $ this -> loaded ) ) { $ this -> notify ( Status :: RESTART ) ; if ( $ this -> prepa...
Checks if xdebug is loaded and the process needs to be restarted
52,119
public static function getAllIniFiles ( ) { if ( ! empty ( self :: $ name ) ) { $ env = getenv ( self :: $ name . self :: SUFFIX_INIS ) ; if ( false !== $ env ) { return explode ( PATH_SEPARATOR , $ env ) ; } } $ paths = array ( ( string ) php_ini_loaded_file ( ) ) ; if ( $ scanned = php_ini_scanned_files ( ) ) { $ pat...
Returns an array of php . ini locations with at least one entry
52,120
public static function getRestartSettings ( ) { $ envArgs = explode ( '|' , ( string ) getenv ( self :: RESTART_SETTINGS ) ) ; if ( count ( $ envArgs ) !== 6 || ( ! self :: $ inRestart && php_ini_loaded_file ( ) !== $ envArgs [ 0 ] ) ) { return ; } return array ( 'tmpIni' => $ envArgs [ 0 ] , 'scannedInis' => ( bool ) ...
Returns an array of restart settings or null
52,121
private function doRestart ( $ command ) { passthru ( $ command , $ exitCode ) ; $ this -> notify ( Status :: INFO , 'Restarted process exited ' . $ exitCode ) ; if ( $ this -> debug === '2' ) { $ this -> notify ( Status :: INFO , 'Temp ini saved: ' . $ this -> tmpIni ) ; } else { @ unlink ( $ this -> tmpIni ) ; } exit...
Executes the restarted command then deletes the tmp ini
52,122
private function prepareRestart ( ) { $ error = '' ; $ iniFiles = self :: getAllIniFiles ( ) ; $ scannedInis = count ( $ iniFiles ) > 1 ; $ tmpDir = sys_get_temp_dir ( ) ; if ( ! $ this -> cli ) { $ error = 'Unsupported SAPI: ' . PHP_SAPI ; } elseif ( ! defined ( 'PHP_BINARY' ) ) { $ error = 'PHP version is too old: ' ...
Returns true if everything was written for the restart
52,123
private function writeTmpIni ( array $ iniFiles , $ tmpDir , & $ error ) { if ( ! $ this -> tmpIni = @ tempnam ( $ tmpDir , '' ) ) { return false ; } if ( empty ( $ iniFiles [ 0 ] ) ) { array_shift ( $ iniFiles ) ; } $ content = '' ; $ regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi' ; foreach ( $ iniFiles as $ file )...
Returns true if the tmp ini file was written
52,124
private function getCommand ( ) { $ php = array ( PHP_BINARY ) ; $ args = array_slice ( $ _SERVER [ 'argv' ] , 1 ) ; if ( ! $ this -> persistent ) { array_push ( $ php , '-n' , '-c' , $ this -> tmpIni ) ; } if ( defined ( 'STDOUT' ) && Process :: supportsColor ( STDOUT ) ) { $ args = Process :: addColorOption ( $ args ...
Returns the restart command line
52,125
private function setEnvironment ( $ scannedInis , array $ iniFiles ) { $ scanDir = getenv ( 'PHP_INI_SCAN_DIR' ) ; $ phprc = getenv ( 'PHPRC' ) ; if ( ! putenv ( $ this -> envOriginalInis . '=' . implode ( PATH_SEPARATOR , $ iniFiles ) ) ) { return false ; } if ( $ this -> persistent ) { if ( ! putenv ( 'PHP_INI_SCAN_D...
Returns true if the restart environment variables were set
52,126
private function mergeLoadedConfig ( array $ loadedConfig , array $ iniConfig ) { $ content = '' ; foreach ( $ loadedConfig as $ name => $ value ) { if ( ! is_string ( $ value ) || strpos ( $ name , 'xdebug' ) === 0 || $ name === 'apc.mmap_file_mask' ) { continue ; } if ( ! isset ( $ iniConfig [ $ name ] ) || $ iniConf...
Returns default changed and command - line ini settings
52,127
private function checkMainScript ( ) { if ( null !== $ this -> script ) { return file_exists ( $ this -> script ) || '--' === $ this -> script ; } if ( file_exists ( $ this -> script = $ _SERVER [ 'argv' ] [ 0 ] ) ) { return true ; } $ options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false ; $ trace = ...
Returns true if the script name can be used
52,128
private function setEnvRestartSettings ( $ envArgs ) { $ settings = array ( php_ini_loaded_file ( ) , $ envArgs [ 2 ] , $ envArgs [ 3 ] , $ envArgs [ 4 ] , getenv ( $ this -> envOriginalInis ) , self :: $ skipped , ) ; Process :: setEnv ( self :: RESTART_SETTINGS , implode ( '|' , $ settings ) ) ; }
Adds restart settings to the environment
52,129
private function syncSettings ( array $ settings ) { if ( false === getenv ( $ this -> envOriginalInis ) ) { Process :: setEnv ( $ this -> envOriginalInis , implode ( PATH_SEPARATOR , $ settings [ 'inis' ] ) ) ; } self :: $ skipped = $ settings [ 'skipped' ] ; $ this -> notify ( Status :: INFO , 'Process called with ex...
Syncs settings and the environment if called with existing settings
52,130
private function checkConfiguration ( & $ info ) { if ( false !== strpos ( ini_get ( 'disable_functions' ) , 'passthru' ) ) { $ info = 'passthru function is disabled' ; return false ; } if ( extension_loaded ( 'uopz' ) ) { if ( function_exists ( 'uopz_allow_exit' ) ) { @ uopz_allow_exit ( true ) ; } else { $ info = 'uo...
Returns true if there are no known configuration issues
52,131
private function getDataAndReset ( ) { if ( $ data = XdebugHandler :: getRestartSettings ( ) ) { Process :: setEnv ( 'PHPRC' , $ data [ 'phprc' ] ) ; Process :: setEnv ( 'PHP_INI_SCAN_DIR' , $ data [ 'scanDir' ] ) ; } return $ data ; }
Returns restart data if available and resets the environment
52,132
public function report ( $ op , $ data ) { if ( $ this -> logger || $ this -> debug ) { call_user_func ( array ( $ this , 'report' . $ op ) , $ data ) ; } }
Calls a handler method to report a message
52,133
private function output ( $ text , $ level = null ) { if ( $ this -> logger ) { $ this -> logger -> log ( $ level ? : LogLevel :: DEBUG , $ text ) ; } if ( $ this -> debug ) { fwrite ( STDERR , sprintf ( 'xdebug-handler[%d] %s' , getmypid ( ) , $ text . PHP_EOL ) ) ; } }
Outputs a status message
52,134
protected function quoteArray ( array $ array ) { array_walk ( $ array , function ( & $ value ) { $ value = $ this -> entityManager -> getConnection ( ) -> quote ( $ value ) ; } ) ; return implode ( ', ' , $ array ) ; }
Quote a PHP array to allow using it in native SQL query
52,135
protected function getGroupLabel ( FamilyInterface $ family , array $ groupPath , $ level ) { $ fallBack = isset ( $ groupPath [ $ level ] ) ? $ groupPath [ $ level ] : null ; $ fieldsetPath = $ this -> getFieldsetPath ( $ groupPath , $ level ) ; $ transKeys = [ "eav.family.{$family->getCode()}.group.{$fieldsetPath}.la...
Use label from formOptions or use translation or automatically create human readable one
52,136
public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ this -> globalConfig = $ config ; $ container -> setParameter ( 'sidus_eav_model.entity.data.class' , $ config [ 'data_class' ...
Generate automatically services for attributes and families from configuration
52,137
public function onFlush ( OnFlushEventArgs $ event ) { $ uow = $ event -> getEntityManager ( ) -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { if ( $ entity instanceof DataInterface && $ this -> hasCreatedEntity ( $ entity -> getFamily ( ) , $ entity -> getIdentifier ( ) ) ) {...
When an entity is created we don t need to keep the reference anymore
52,138
protected function fixDoctrineQueryBuilderNormalizer ( OptionsResolver $ resolver ) { $ queryBuilderNormalizer = function ( Options $ options , $ queryBuilder ) { if ( \ is_callable ( $ queryBuilder ) ) { $ queryBuilder = $ queryBuilder ( $ this -> entityManager -> getRepository ( $ options [ 'class' ] ) , $ options ) ...
Adding an options parameter in the query builder normalizer Taken directly from \ Symfony \ Bridge \ Doctrine \ Form \ Type \ EntityType
52,139
public function getMatchingCodes ( ) { $ codes = [ $ this -> getCode ( ) ] ; foreach ( $ this -> getChildren ( ) as $ child ) { $ codes = array_merge ( $ codes , $ child -> getMatchingCodes ( ) ) ; } return $ codes ; }
Return current family code and all it s sub - families codes
52,140
protected function isAllowedEAVAttribute ( DataInterface $ object , AttributeInterface $ attribute , $ format = null , array $ context = [ ] ) { $ options = $ attribute -> getOption ( static :: SERIALIZER_OPTIONS , [ ] ) ; if ( array_key_exists ( static :: EXPOSE_KEY , $ options ) && ! $ options [ static :: EXPOSE_KEY ...
Is this EAV attribute allowed?
52,141
public function isContextMatching ( ContextualValueInterface $ value , array $ context ) { if ( ! $ value -> getContext ( ) ) { return true ; } $ value :: checkContext ( $ context ) ; foreach ( $ this -> getContextMask ( ) as $ key ) { $ contextKey = array_key_exists ( $ key , $ context ) ? $ context [ $ key ] : null ;...
Warning the context array must contain all context axis
52,142
public function getRootFamilies ( ) { $ root = [ ] ; foreach ( $ this -> getFamilies ( ) as $ family ) { if ( $ family -> isInstantiable ( ) ) { $ p = $ family -> getParent ( ) ; if ( ! $ p || ( $ p && ! $ p -> isInstantiable ( ) ) ) { $ root [ $ family -> getCode ( ) ] = $ family ; } } } return $ root ; }
Get all instantiable families with no parent
52,143
public function findByIdentifier ( FamilyInterface $ family , $ reference , $ idFallback = false , $ partialLoad = false ) { $ identifierAttribute = $ family -> getAttributeAsIdentifier ( ) ; if ( ! $ identifierAttribute ) { if ( ! $ idFallback ) { $ m = "Cannot find data with no identifier attribute for family: '{$fam...
Find data based on it s family identifier
52,144
public function findByUniqueAttribute ( FamilyInterface $ family , AttributeInterface $ attribute , $ reference , $ partialLoad = false ) { if ( ! $ attribute -> isUnique ( ) ) { throw new \ LogicException ( "Cannot find data based on a non-unique attribute '{$attribute->getCode()}'" ) ; } $ dataBaseType = $ attribute ...
Find a data based on a unique attribute
52,145
public function findByIdentifierColumn ( FamilyInterface $ family , $ identifierColumn , $ reference , $ partialLoad = false ) { if ( ! $ partialLoad ) { return $ this -> findOneBy ( [ $ identifierColumn => $ reference , 'family' => $ family , ] ) ; } $ qb = $ this -> createQueryBuilder ( 'e' ) -> where ( "e.{$identifi...
Find data based on a identifier column present in the Data entity
52,146
public function getInstance ( FamilyInterface $ family ) { if ( ! $ family -> isSingleton ( ) ) { throw new \ LogicException ( "Family {$family->getCode()} is not a singleton" ) ; } $ qb = $ this -> createQueryBuilder ( 'e' ) -> andWhere ( 'e.family = :familyCode' ) -> join ( 'e.values' , 'values' ) -> setParameters ( ...
Return singleton for a given family
52,147
public function createFamilyQueryBuilder ( FamilyInterface $ family , $ alias = 'e' ) { return new SingleFamilyQueryBuilder ( $ family , $ this -> createQueryBuilder ( $ alias ) , $ alias ) ; }
Returns a EAVQueryBuilder to allow you to build a complex query to search your database
52,148
public function getQbForFamiliesAndLabel ( array $ families , $ term ) { if ( '%%' === $ term ) { $ term = '%' ; } if ( '%' === $ term ) { return $ this -> repository -> getQbForFamilies ( $ families ) ; } $ eavQb = $ this -> repository -> createEAVQueryBuilder ( ) ; $ orCondition = [ ] ; foreach ( $ families as $ fami...
This method was moved from the DataRepository because it depends on the FamilyRegistry to resolve sub families
52,149
public function addValueData ( AttributeInterface $ attribute , $ valueData , array $ context = null ) { $ this -> checkAttribute ( $ attribute ) ; if ( ! $ attribute -> isCollection ( ) ) { $ m = "Cannot append data to a non-collection attribute '{$attribute->getCode()}'" ; throw new InvalidValueDataException ( $ m ) ...
Append data to an attribute
52,150
public function removeValueData ( AttributeInterface $ attribute , $ valueData , array $ context = null ) { $ this -> checkAttribute ( $ attribute ) ; if ( ! $ attribute -> isCollection ( ) ) { $ m = "Cannot remove data from a non-collection attribute '{$attribute->getCode()}'" ; throw new InvalidValueDataException ( $...
Remove a data from an attribute
52,151
public function getValueData ( AttributeInterface $ attribute , array $ context = null ) { $ valuesData = $ this -> getValuesData ( $ attribute , $ context ) ; return 0 === \ count ( $ valuesData ) ? null : $ valuesData -> first ( ) ; }
Get the value data of the value matching the attribute
52,152
public function getValuesData ( AttributeInterface $ attribute , array $ context = null ) { $ this -> checkAttribute ( $ attribute ) ; $ valuesData = new ArrayCollection ( ) ; try { foreach ( $ this -> getValues ( $ attribute , $ context ) as $ value ) { $ valuesData -> add ( $ value -> getValueData ( ) ) ; } } catch (...
Get the values data of multiple values for a given attribute
52,153
public function get ( $ attributeCode , array $ context = null ) { $ attribute = $ this -> getAttribute ( $ attributeCode ) ; $ getter = 'get' . ucfirst ( $ attributeCode ) ; if ( method_exists ( $ this , $ getter ) ) { return $ this -> $ getter ( $ context ) ; } if ( $ attribute -> isCollection ( ) ) { return $ this -...
Used to get values in a simple way
52,154
public function set ( $ attributeCode , $ value , array $ context = null ) { $ attribute = $ this -> getAttribute ( $ attributeCode ) ; $ method = 'set' . ucfirst ( $ attributeCode ) ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( $ value , $ context ) ; } if ( $ attribute -> isCollection ( )...
Used to set values as in a simple way
52,155
public function add ( $ attributeCode , $ value , array $ context = null ) { $ attribute = $ this -> getAttribute ( $ attributeCode ) ; $ method = 'add' . ucfirst ( $ attributeCode ) ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( $ value , $ context ) ; } return $ this -> addValueData ( $ at...
Append a new value to a collection
52,156
public function remove ( $ attributeCode , $ value , array $ context = null ) { $ attribute = $ this -> getAttribute ( $ attributeCode ) ; $ method = 'remove' . ucfirst ( $ attributeCode ) ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( $ value , $ context ) ; } return $ this -> removeValueDa...
Search the value in the collection and remove it
52,157
public function getValue ( AttributeInterface $ attribute , array $ context = null ) { $ values = $ this -> getValues ( $ attribute , $ context ) ; return 0 === \ count ( $ values ) ? null : $ values -> first ( ) ; }
Return first value found for attribute code in value collection
52,158
public function getValues ( AttributeInterface $ attribute = null , array $ context = null ) { $ values = $ this -> getInternalValues ( $ attribute , $ context ) ; if ( $ attribute && 0 === \ count ( $ values ) && null !== $ attribute -> getDefault ( ) ) { return $ this -> createDefaultValues ( $ attribute , $ context ...
Return all values matching the attribute code
52,159
public function setValuesData ( AttributeInterface $ attribute , $ dataValues , array $ context = null ) { $ this -> setInternalValuesData ( $ attribute , $ dataValues , $ context ) ; return $ this ; }
Set the values data of a given attribute for multiple fields
52,160
public function setValueData ( AttributeInterface $ attribute , $ dataValue , array $ context = null ) { return $ this -> setValuesData ( $ attribute , [ $ dataValue ] , $ context ) ; }
Set the value s data of a given attribute
52,161
protected function getValuesByAttribute ( AttributeInterface $ attribute ) { if ( null === $ this -> valuesByAttributes ) { $ this -> valuesByAttributes = [ ] ; } if ( ! array_key_exists ( $ attribute -> getCode ( ) , $ this -> valuesByAttributes ) ) { $ this -> valuesByAttributes [ $ attribute -> getCode ( ) ] = [ ] ;...
Cache internally the values indexed by their attribute codes to increase performances
52,162
public function setContext ( array $ context ) { $ context = array_merge ( $ this -> getDefaultContext ( ) , $ context ) ; $ this -> context = $ context ; if ( $ this -> session ) { $ this -> session -> set ( static :: SESSION_KEY , $ context ) ; $ this -> session -> save ( ) ; } }
This method is exposed only for command - line applications please use the context selector form
52,163
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ this -> requestUri = $ request -> getRequestUri ( ) ; try { $ this -> session = $ request -> getSession ( ) ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( "Unable to access session: {$e->getMessage()}" ...
Global hook checking if context form was submitted because the context form can appear on any page
52,164
protected function getRequestAttributeName ( Request $ request , ParamConverter $ configuration ) { $ param = parent :: getRequestAttributeName ( $ request , $ configuration ) ; if ( ! $ request -> attributes -> has ( $ param ) ) { if ( $ request -> attributes -> has ( 'dataId' ) ) { $ param = 'dataId' ; } elseif ( $ r...
Allow fallback to dataId or id in case no attribute is found
52,165
public function join ( $ alias = null ) { if ( null === $ alias ) { $ alias = $ this -> generateUniqueId ( 'join' ) ; } $ this -> joinRelation = $ alias ; $ this -> applyJoin ( ) ; $ joinedEAVQb = new EAVQueryBuilder ( $ this -> eavQueryBuilder -> getQueryBuilder ( ) , $ alias ) ; $ joinedEAVQb -> setContext ( $ this -...
Use this attribute to join on a related entity . Returns an EAVQueryBuilder by default but can be used for other Doctrine entities too .
52,166
public function applyJoin ( ) { if ( $ this -> skipJoin ) { return $ this ; } $ attributeCode = $ this -> attribute -> getCode ( ) ; if ( $ this -> joinApplied ) { throw new \ LogicException ( "Join for attribute query builder {$attributeCode} already applied" ) ; } $ qb = $ this -> eavQueryBuilder -> getQueryBuilder (...
Apply the join condition on the Query Builder
52,167
public function emitBufferedEvents ( ) { $ result = [ ] ; while ( $ event = array_shift ( $ this -> bufferedEvents ) ) { $ result [ ] = parent :: emit ( $ event ) ; } return $ result ; }
Emit the buffered events .
52,168
protected function invokeListeners ( $ name , EventInterface $ event , array $ arguments ) { $ listeners = $ this -> getListeners ( $ name ) ; foreach ( $ listeners as $ listener ) { if ( $ event -> isPropagationStopped ( ) ) { break ; } call_user_func_array ( [ $ listener , 'handle' ] , $ arguments ) ; } }
Invoke the listeners for an event .
52,169
protected function prepareEvent ( $ event ) { $ event = $ this -> ensureEvent ( $ event ) ; $ name = $ event -> getName ( ) ; $ event -> setEmitter ( $ this ) ; return [ $ name , $ event ] ; }
Prepare an event for emitting .
52,170
protected function ensureEvent ( $ event ) { if ( is_string ( $ event ) ) { return Event :: named ( $ event ) ; } if ( ! $ event instanceof EventInterface ) { throw new InvalidArgumentException ( 'Events should be provides as Event instances or string, received type: ' . gettype ( $ event ) ) ; } return $ event ; }
Ensure event input is of type EventInterface or convert it .
52,171
public function addOneTimeListener ( $ event , $ listener , $ priority = ListenerAcceptorInterface :: P_NORMAL ) { $ this -> getEmitter ( ) -> addOneTimeListener ( $ event , $ listener , $ priority ) ; return $ this ; }
Add a one time listener for an event .
52,172
public function then ( callable $ onFulfilled = null , callable $ onRejected = null ) { if ( $ onFulfilled ) { $ this -> core -> addOnFulfilled ( $ onFulfilled ) ; } if ( $ onRejected ) { $ this -> core -> addOnRejected ( $ onRejected ) ; } return new self ( $ this -> core , $ this -> runner ) ; }
Add behavior for when the promise is resolved or rejected .
52,173
public function wait ( $ unwrap = true ) { $ this -> runner -> wait ( $ this -> core ) ; if ( $ unwrap ) { if ( $ this -> core -> getState ( ) === self :: REJECTED ) { throw $ this -> core -> getException ( ) ; } return $ this -> core -> getResponse ( ) ; } return null ; }
Wait for the promise to be fulfilled or rejected .
52,174
public function sendRequest ( RequestInterface $ request ) : ResponseInterface { $ responseBuilder = $ this -> createResponseBuilder ( ) ; $ requestOptions = $ this -> prepareRequestOptions ( $ request , $ responseBuilder ) ; if ( is_resource ( $ this -> handle ) ) { curl_reset ( $ this -> handle ) ; } else { $ this ->...
Sends a PSR - 7 request and returns a PSR - 7 response .
52,175
private function createResponseBuilder ( ) : ResponseBuilder { $ body = $ this -> streamFactory -> createStreamFromFile ( 'php://temp' , 'w+b' ) ; $ response = $ this -> responseFactory -> createResponse ( 200 ) -> withBody ( $ body ) ; return new ResponseBuilder ( $ response ) ; }
Create builder to use for building response object .
52,176
private function prepareRequestOptions ( RequestInterface $ request , ResponseBuilder $ responseBuilder ) : array { $ curlOptions = $ this -> curlOptions ; try { $ curlOptions [ CURLOPT_HTTP_VERSION ] = $ this -> getProtocolVersion ( $ request -> getProtocolVersion ( ) ) ; } catch ( \ UnexpectedValueException $ e ) { t...
Update cURL options for given request and hook in the response builder .
52,177
private function getProtocolVersion ( string $ requestVersion ) : int { switch ( $ requestVersion ) { case '1.0' : return CURL_HTTP_VERSION_1_0 ; case '1.1' : return CURL_HTTP_VERSION_1_1 ; case '2.0' : if ( defined ( 'CURL_HTTP_VERSION_2_0' ) ) { return CURL_HTTP_VERSION_2_0 ; } throw new \ UnexpectedValueException ( ...
Return cURL constant for specified HTTP version .
52,178
private function addRequestBodyOptions ( RequestInterface $ request , array $ curlOptions ) : array { if ( ! in_array ( $ request -> getMethod ( ) , [ 'GET' , 'HEAD' , 'TRACE' ] , true ) ) { $ body = $ request -> getBody ( ) ; $ bodySize = $ body -> getSize ( ) ; if ( $ bodySize !== 0 ) { if ( $ body -> isSeekable ( ) ...
Add request body related cURL options .
52,179
private function createHeaders ( RequestInterface $ request , array $ curlOptions ) : array { $ curlHeaders = [ ] ; $ headers = $ request -> getHeaders ( ) ; foreach ( $ headers as $ name => $ values ) { $ header = strtolower ( $ name ) ; if ( 'expect' === $ header ) { continue ; } if ( 'content-length' === $ header ) ...
Create headers array for CURLOPT_HTTPHEADER .
52,180
public function sendAsyncRequest ( RequestInterface $ request ) { if ( ! $ this -> multiRunner instanceof MultiRunner ) { $ this -> multiRunner = new MultiRunner ( ) ; } $ handle = curl_init ( ) ; $ responseBuilder = $ this -> createResponseBuilder ( ) ; $ requestOptions = $ this -> prepareRequestOptions ( $ request , ...
Sends a PSR - 7 request in an asynchronous way .
52,181
public function add ( PromiseCore $ core ) : void { foreach ( $ this -> cores as $ existed ) { if ( $ existed === $ core ) { return ; } } $ this -> cores [ ] = $ core ; if ( null === $ this -> multiHandle ) { $ this -> multiHandle = curl_multi_init ( ) ; } curl_multi_add_handle ( $ this -> multiHandle , $ core -> getHa...
Add promise to runner .
52,182
public function remove ( PromiseCore $ core ) : void { foreach ( $ this -> cores as $ index => $ existed ) { if ( $ existed === $ core ) { curl_multi_remove_handle ( $ this -> multiHandle , $ core -> getHandle ( ) ) ; unset ( $ this -> cores [ $ index ] ) ; return ; } } }
Remove promise from runner .
52,183
private function findCoreByHandle ( $ handle ) : ? PromiseCore { foreach ( $ this -> cores as $ core ) { if ( $ core -> getHandle ( ) === $ handle ) { return $ core ; } } return null ; }
Find core by handle .
52,184
public function addOnFulfilled ( callable $ callback ) : void { if ( $ this -> getState ( ) === Promise :: PENDING ) { $ this -> onFulfilled [ ] = $ callback ; } elseif ( $ this -> getState ( ) === Promise :: FULFILLED ) { $ response = call_user_func ( $ callback , $ this -> responseBuilder -> getResponse ( ) ) ; if ( ...
Add on fulfilled callback .
52,185
public function addOnRejected ( callable $ callback ) : void { if ( $ this -> getState ( ) === Promise :: PENDING ) { $ this -> onRejected [ ] = $ callback ; } elseif ( $ this -> getState ( ) === Promise :: REJECTED ) { $ this -> exception = call_user_func ( $ callback , $ this -> exception ) ; } }
Add on rejected callback .
52,186
public function fulfill ( ) : void { $ this -> state = Promise :: FULFILLED ; $ response = $ this -> responseBuilder -> getResponse ( ) ; try { $ response -> getBody ( ) -> seek ( 0 ) ; } catch ( \ RuntimeException $ e ) { $ exception = new Exception \ TransferException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ ...
Fulfill promise .
52,187
public function reject ( Exception $ exception ) : void { $ this -> exception = $ exception ; $ this -> state = Promise :: REJECTED ; while ( count ( $ this -> onRejected ) > 0 ) { $ callback = array_shift ( $ this -> onRejected ) ; try { $ exception = call_user_func ( $ callback , $ this -> exception ) ; $ this -> exc...
Reject promise .
52,188
private function drain ( $ stream , $ dest ) { if ( is_resource ( $ stream ) ) { if ( ! is_resource ( $ dest ) ) { $ stream = Stream :: factory ( $ stream ) ; } else { stream_copy_to_stream ( $ stream , $ dest ) ; fclose ( $ stream ) ; rewind ( $ dest ) ; return $ dest ; } } $ dest = is_string ( $ dest ) ? new Stream (...
Drains the stream into the save_to client option .
52,189
public static function createResponse ( callable $ handler , array $ request , array $ response , array $ headers , $ body ) { if ( isset ( $ response [ 'transfer_stats' ] [ 'url' ] ) ) { $ response [ 'effective_url' ] = $ response [ 'transfer_stats' ] [ 'url' ] ; } if ( ! empty ( $ headers ) ) { $ startLine = explode ...
Creates a response hash from a cURL result .
52,190
public static function getDefaultCaBundle ( ) { static $ cached = null ; static $ cafiles = [ '/etc/pki/tls/certs/ca-bundle.crt' , '/etc/ssl/certs/ca-certificates.crt' , '/usr/local/share/certs/ca-root-nss.crt' , '/usr/local/etc/openssl/cert.pem' , 'C:\\windows\\system32\\curl-ca-bundle.crt' , 'C:\\windows\\curl-ca-bun...
Returns the default cacert bundle for the current system .
52,191
public static function headerLines ( $ message , $ header ) { $ result = [ ] ; if ( ! empty ( $ message [ 'headers' ] ) ) { foreach ( $ message [ 'headers' ] as $ name => $ value ) { if ( ! strcasecmp ( $ name , $ header ) ) { $ result = array_merge ( $ result , $ value ) ; } } } return $ result ; }
Gets an array of header line values from a message for a specific header
52,192
public static function header ( $ message , $ header ) { $ match = self :: headerLines ( $ message , $ header ) ; return $ match ? implode ( ', ' , $ match ) : null ; }
Gets a header value from a message as a string or null
52,193
public static function firstHeader ( $ message , $ header ) { if ( ! empty ( $ message [ 'headers' ] ) ) { foreach ( $ message [ 'headers' ] as $ name => $ value ) { if ( ! strcasecmp ( $ name , $ header ) ) { $ pos = strpos ( $ value [ 0 ] , ',' ) ; return $ pos ? substr ( $ value [ 0 ] , 0 , $ pos ) : $ value [ 0 ] ;...
Returns the first header value from a message as a string or null . If a header line contains multiple values separated by a comma then this function will return the first value in the list .
52,194
public static function hasHeader ( $ message , $ header ) { if ( ! empty ( $ message [ 'headers' ] ) ) { foreach ( $ message [ 'headers' ] as $ name => $ value ) { if ( ! strcasecmp ( $ name , $ header ) ) { return true ; } } } return false ; }
Returns true if a message has the provided case - insensitive header .
52,195
public static function headersFromLines ( $ lines ) { $ headers = [ ] ; foreach ( $ lines as $ line ) { $ parts = explode ( ':' , $ line , 2 ) ; $ headers [ trim ( $ parts [ 0 ] ) ] [ ] = isset ( $ parts [ 1 ] ) ? trim ( $ parts [ 1 ] ) : null ; } return $ headers ; }
Parses an array of header lines into an associative array of headers .
52,196
public static function removeHeader ( array $ message , $ header ) { if ( isset ( $ message [ 'headers' ] ) ) { foreach ( array_keys ( $ message [ 'headers' ] ) as $ key ) { if ( ! strcasecmp ( $ header , $ key ) ) { unset ( $ message [ 'headers' ] [ $ key ] ) ; } } } return $ message ; }
Removes a header from a message using a case - insensitive comparison .
52,197
public static function setHeader ( array $ message , $ header , array $ value ) { $ message = self :: removeHeader ( $ message , $ header ) ; $ message [ 'headers' ] [ $ header ] = $ value ; return $ message ; }
Replaces any existing case insensitive headers with the given value .
52,198
public static function url ( array $ request ) { if ( isset ( $ request [ 'url' ] ) ) { return $ request [ 'url' ] ; } $ uri = ( isset ( $ request [ 'scheme' ] ) ? $ request [ 'scheme' ] : 'http' ) . '://' ; if ( $ host = self :: header ( $ request , 'host' ) ) { $ uri .= $ host ; } else { throw new \ InvalidArgumentEx...
Creates a URL string from a request .
52,199
public static function body ( $ message ) { if ( ! isset ( $ message [ 'body' ] ) ) { return null ; } if ( $ message [ 'body' ] instanceof StreamInterface ) { return ( string ) $ message [ 'body' ] ; } switch ( gettype ( $ message [ 'body' ] ) ) { case 'string' : return $ message [ 'body' ] ; case 'resource' : return s...
Reads the body of a message into a string .