idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
21,900
public function getRequestFormat ( $ default = 'html' ) { if ( null === $ this -> format ) { $ this -> format = $ this -> attributes -> get ( '_format' ) ; } return null === $ this -> format ? $ default : $ this -> format ; }
Gets the request format .
21,901
public function getProtocolVersion ( ) { if ( $ this -> isFromTrustedProxy ( ) ) { preg_match ( '~^(HTTP/)?([1-9]\.[0-9]) ~' , $ this -> headers -> get ( 'Via' ) , $ matches ) ; if ( $ matches ) { return 'HTTP/' . $ matches [ 2 ] ; } } return $ this -> server -> get ( 'SERVER_PROTOCOL' ) ; }
Returns the protocol version .
21,902
public function getPreferredLanguage ( array $ locales = null ) { $ preferredLanguages = $ this -> getLanguages ( ) ; if ( empty ( $ locales ) ) { return isset ( $ preferredLanguages [ 0 ] ) ? $ preferredLanguages [ 0 ] : null ; } if ( ! $ preferredLanguages ) { return $ locales [ 0 ] ; } $ extendedPreferredLanguages =...
Returns the preferred language .
21,903
public function getAcceptableContentTypes ( ) { if ( null !== $ this -> acceptableContentTypes ) { return $ this -> acceptableContentTypes ; } return $ this -> acceptableContentTypes = array_keys ( AcceptHeader :: fromString ( $ this -> headers -> get ( 'Accept' ) ) -> all ( ) ) ; }
Gets a list of content types acceptable by the client browser .
21,904
protected function prepareBasePath ( ) { $ baseUrl = $ this -> getBaseUrl ( ) ; if ( empty ( $ baseUrl ) ) { return '' ; } $ filename = basename ( $ this -> server -> get ( 'SCRIPT_FILENAME' ) ) ; if ( basename ( $ baseUrl ) === $ filename ) { $ basePath = \ dirname ( $ baseUrl ) ; } else { $ basePath = $ baseUrl ; } i...
Prepares the base path .
21,905
public function setCircularReferenceLimit ( $ circularReferenceLimit ) { @ trigger_error ( sprintf ( 'The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_limit" key of the context instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ this -> defaultContext [ self :: CIRCULAR_REFERENCE_LIMIT ] = ...
Sets circular reference limit .
21,906
public function setCircularReferenceHandler ( callable $ circularReferenceHandler ) { @ trigger_error ( sprintf ( 'The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_handler" key of the context instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ this -> defaultContext [ self :: CIRCULAR_REFER...
Sets circular reference handler .
21,907
public function setCallbacks ( array $ callbacks ) { @ trigger_error ( sprintf ( 'The "%s()" method is deprecated since Symfony 4.2, use the "callbacks" key of the context instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; foreach ( $ callbacks as $ attribute => $ callback ) { if ( ! \ is_callable ( $ callback ) ) { thro...
Sets normalization callbacks .
21,908
public function setIgnoredAttributes ( array $ ignoredAttributes ) { @ trigger_error ( sprintf ( 'The "%s()" method is deprecated since Symfony 4.2, use the "ignored_attributes" key of the context instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ this -> defaultContext [ self :: IGNORED_ATTRIBUTES ] = $ this -> ignore...
Sets ignored attributes for normalization and denormalization .
21,909
private function createUserProviders ( $ config , ContainerBuilder $ container ) { $ providerIds = [ ] ; foreach ( $ config [ 'providers' ] as $ name => $ provider ) { $ id = $ this -> createUserDaoProvider ( $ name , $ provider , $ container ) ; $ providerIds [ str_replace ( '-' , '_' , $ name ) ] = $ id ; } return $ ...
Parses user providers and returns an array of their ids
21,910
public static function getCurrencyBundle ( ) { @ trigger_error ( sprintf ( 'The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.' , __METHOD__ , Currencies :: class ) , E_USER_DEPRECATED ) ; if ( null === self :: $ currencyBundle ) { self :: $ currencyBundle = new CurrencyBundle ( self :: getDataDirecto...
Returns the bundle containing currency information .
21,911
public static function getLanguageBundle ( ) { @ trigger_error ( sprintf ( 'The method "%s()" is deprecated since Symfony 4.3, use "%s" or "%s" instead.' , __METHOD__ , Languages :: class , Scripts :: class ) , E_USER_DEPRECATED ) ; if ( null === self :: $ languageBundle ) { self :: $ languageBundle = new LanguageBundl...
Returns the bundle containing language information .
21,912
public static function getLocaleBundle ( ) { @ trigger_error ( sprintf ( 'The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.' , __METHOD__ , Locales :: class ) , E_USER_DEPRECATED ) ; if ( null === self :: $ localeBundle ) { self :: $ localeBundle = new LocaleBundle ( self :: getDataDirectory ( ) . '/...
Returns the bundle containing locale information .
21,913
public static function getRegionBundle ( ) { @ trigger_error ( sprintf ( 'The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.' , __METHOD__ , Regions :: class ) , E_USER_DEPRECATED ) ; if ( null === self :: $ regionBundle ) { self :: $ regionBundle = new RegionBundle ( self :: getDataDirectory ( ) . '/...
Returns the bundle containing region information .
21,914
public static function getIcuVersion ( ) { if ( false === self :: $ icuVersion ) { if ( ! self :: isExtensionLoaded ( ) ) { self :: $ icuVersion = self :: getIcuStubVersion ( ) ; } elseif ( \ defined ( 'INTL_ICU_VERSION' ) ) { self :: $ icuVersion = INTL_ICU_VERSION ; } else { try { $ reflector = new \ ReflectionExtens...
Returns the version of the installed ICU library .
21,915
public static function getIcuDataVersion ( ) { if ( false === self :: $ icuDataVersion ) { self :: $ icuDataVersion = trim ( file_get_contents ( self :: getDataDirectory ( ) . '/version.txt' ) ) ; } return self :: $ icuDataVersion ; }
Returns the version of the installed ICU data .
21,916
private static function getEntryReader ( ) { if ( null === self :: $ entryReader ) { self :: $ entryReader = new BundleEntryReader ( new BufferedBundleReader ( new JsonBundleReader ( ) , self :: BUFFER_SIZE ) ) ; $ localeDataProvider = new LocaleDataProvider ( self :: getDataDirectory ( ) . '/' . self :: LOCALE_DIR , s...
Returns the cached bundle entry reader .
21,917
public function getName ( Profile $ profile , $ panel ) { $ templates = $ this -> getNames ( $ profile ) ; if ( ! isset ( $ templates [ $ panel ] ) ) { throw new NotFoundHttpException ( sprintf ( 'Panel "%s" is not registered in profiler or is not present in viewed profile.' , $ panel ) ) ; } return $ templates [ $ pan...
Gets the template name for a given panel .
21,918
public function getNames ( Profile $ profile ) { $ templates = [ ] ; foreach ( $ this -> templates as $ arguments ) { if ( null === $ arguments ) { continue ; } list ( $ name , $ template ) = $ arguments ; if ( ! $ this -> profiler -> has ( $ name ) || ! $ profile -> hasCollector ( $ name ) ) { continue ; } if ( '.html...
Gets template names of templates that are present in the viewed profile .
21,919
protected function templateExists ( $ template ) { $ loader = $ this -> twig -> getLoader ( ) ; if ( $ loader instanceof ExistsLoaderInterface ) { return $ loader -> exists ( $ template ) ; } try { if ( $ loader instanceof SourceContextLoaderInterface || method_exists ( $ loader , 'getSourceContext' ) ) { $ loader -> g...
to be removed when the minimum required version of Twig is > = 2 . 0
21,920
public static function getRelativePath ( $ basePath , $ targetPath ) { if ( $ basePath === $ targetPath ) { return '' ; } $ sourceDirs = explode ( '/' , isset ( $ basePath [ 0 ] ) && '/' === $ basePath [ 0 ] ? substr ( $ basePath , 1 ) : $ basePath ) ; $ targetDirs = explode ( '/' , isset ( $ targetPath [ 0 ] ) && '/' ...
Returns the target path as relative reference from the base path .
21,921
public function getReflectionMember ( $ objectOrClassName ) { $ className = \ is_string ( $ objectOrClassName ) ? $ objectOrClassName : \ get_class ( $ objectOrClassName ) ; if ( ! isset ( $ this -> reflMember [ $ className ] ) ) { $ this -> reflMember [ $ className ] = $ this -> newReflectionMember ( $ objectOrClassNa...
Returns the reflection instance for accessing the member s value .
21,922
public function getPropertyAccessor ( ) { return new PropertyAccessor ( $ this -> magicCall , $ this -> throwExceptionOnInvalidIndex , $ this -> cacheItemPool , $ this -> throwExceptionOnInvalidPropertyPath ) ; }
Builds and returns a new PropertyAccessor object .
21,923
public function remap ( $ key , $ plural = null ) { $ this -> remappings [ ] = [ $ key , null === $ plural ? $ key . 's' : $ plural ] ; return $ this ; }
Registers a key to remap to its plural form .
21,924
public function before ( \ Closure $ closure = null ) { if ( null !== $ closure ) { $ this -> before [ ] = $ closure ; return $ this ; } return $ this -> before [ ] = new ExprBuilder ( $ this -> node ) ; }
Registers a closure to run before the normalization or an expression builder to build it if null is provided .
21,925
private function filterResponse ( Response $ response , Request $ request , int $ type ) { $ event = new ResponseEvent ( $ this , $ request , $ type , $ response ) ; $ this -> dispatcher -> dispatch ( $ event , KernelEvents :: RESPONSE ) ; $ this -> finishRequest ( $ request , $ type ) ; return $ event -> getResponse (...
Filters a response object .
21,926
private function finishRequest ( Request $ request , int $ type ) { $ this -> dispatcher -> dispatch ( new FinishRequestEvent ( $ this , $ request , $ type ) , KernelEvents :: FINISH_REQUEST ) ; $ this -> requestStack -> pop ( ) ; }
Publishes the finish request event then pop the request from the stack .
21,927
public static function fromPhp ( $ phpFunctionName , $ expressionFunctionName = null ) { $ phpFunctionName = ltrim ( $ phpFunctionName , '\\' ) ; if ( ! \ function_exists ( $ phpFunctionName ) ) { throw new \ InvalidArgumentException ( sprintf ( 'PHP function "%s" does not exist.' , $ phpFunctionName ) ) ; } $ parts = ...
Creates an ExpressionFunction from a PHP function name .
21,928
public function getFallbackLocales ( ) { if ( $ this -> translator instanceof Translator || method_exists ( $ this -> translator , 'getFallbackLocales' ) ) { return $ this -> translator -> getFallbackLocales ( ) ; } return [ ] ; }
Gets the fallback locales .
21,929
public function getHeaders ( ) { $ headers = [ ] ; $ contentHeaders = [ 'CONTENT_LENGTH' => true , 'CONTENT_MD5' => true , 'CONTENT_TYPE' => true ] ; foreach ( $ this -> parameters as $ key => $ value ) { if ( 0 === strpos ( $ key , 'HTTP_' ) ) { $ headers [ substr ( $ key , 5 ) ] = $ value ; } elseif ( isset ( $ conte...
Gets the HTTP headers .
21,930
private function getResponse ( string $ secret , string $ challenge ) : string { if ( \ strlen ( $ secret ) > 64 ) { $ secret = pack ( 'H32' , md5 ( $ secret ) ) ; } if ( \ strlen ( $ secret ) < 64 ) { $ secret = str_pad ( $ secret , 64 , \ chr ( 0 ) ) ; } $ kipad = substr ( $ secret , 0 , 64 ) ^ str_repeat ( \ chr ( 0...
Generates a CRAM - MD5 response from a server challenge .
21,931
private function moveToNextLine ( ) : bool { if ( $ this -> currentLineNb >= \ count ( $ this -> lines ) - 1 ) { return false ; } $ this -> currentLine = $ this -> lines [ ++ $ this -> currentLineNb ] ; return true ; }
Moves the parser to the next line .
21,932
private function moveToPreviousLine ( ) : bool { if ( $ this -> currentLineNb < 1 ) { return false ; } $ this -> currentLine = $ this -> lines [ -- $ this -> currentLineNb ] ; return true ; }
Moves the parser to the previous line .
21,933
public function clear ( ) { $ this -> places = [ ] ; $ this -> transitions = [ ] ; $ this -> initialPlace = null ; $ this -> metadataStore = null ; return $ this ; }
Clear all data in the builder .
21,934
public function setValues ( array $ values ) { foreach ( $ values as $ name => $ value ) { $ this -> fields -> set ( $ name , $ value ) ; } return $ this ; }
Sets the value of the fields .
21,935
public function getUri ( ) { $ uri = parent :: getUri ( ) ; if ( ! \ in_array ( $ this -> getMethod ( ) , [ 'POST' , 'PUT' , 'DELETE' , 'PATCH' ] ) ) { $ query = parse_url ( $ uri , PHP_URL_QUERY ) ; $ currentParameters = [ ] ; if ( $ query ) { parse_str ( $ query , $ currentParameters ) ; } $ queryString = http_build_...
Gets the URI of the form .
21,936
public function getMethod ( ) { if ( null !== $ this -> method ) { return $ this -> method ; } if ( $ this -> button !== $ this -> node && $ this -> button -> getAttribute ( 'formmethod' ) ) { return strtoupper ( $ this -> button -> getAttribute ( 'formmethod' ) ) ; } return $ this -> node -> getAttribute ( 'method' ) ...
Gets the form method .
21,937
public function disableValidation ( ) { foreach ( $ this -> fields -> all ( ) as $ field ) { if ( $ field instanceof Field \ ChoiceFormField ) { $ field -> disableValidation ( ) ; } } return $ this ; }
Disables validation .
21,938
protected function setNode ( \ DOMElement $ node ) { $ this -> button = $ node ; if ( 'button' === $ node -> nodeName || ( 'input' === $ node -> nodeName && \ in_array ( strtolower ( $ node -> getAttribute ( 'type' ) ) , [ 'submit' , 'button' , 'image' ] ) ) ) { if ( $ node -> hasAttribute ( 'form' ) ) { $ formId = $ n...
Sets the node for the form .
21,939
private function initialize ( ) { $ this -> fields = new FormFieldRegistry ( ) ; $ xpath = new \ DOMXPath ( $ this -> node -> ownerDocument ) ; if ( 'form' !== $ this -> button -> nodeName && $ this -> button -> hasAttribute ( 'name' ) && $ this -> button -> getAttribute ( 'name' ) ) { if ( 'input' == $ this -> button ...
Adds form elements related to this form .
21,940
private function isWindowsTrueColor ( ) { $ result = 183 <= getenv ( 'ANSICON_VER' ) || 'ON' === getenv ( 'ConEmuANSI' ) || 'xterm' === getenv ( 'TERM' ) || 'Hyper' === getenv ( 'TERM_PROGRAM' ) ; if ( ! $ result && \ PHP_VERSION_ID >= 70200 ) { $ version = sprintf ( '%s.%s.%s' , PHP_WINDOWS_VERSION_MAJOR , PHP_WINDOWS...
Returns true if the Windows terminal supports true color .
21,941
public function getNode ( $ forceRootNode = false ) { if ( $ forceRootNode ) { $ this -> parent = null ; } if ( null !== $ this -> normalization ) { $ this -> normalization -> before = ExprBuilder :: buildExpressions ( $ this -> normalization -> before ) ; } if ( null !== $ this -> validation ) { $ this -> validation -...
Creates the node .
21,942
protected function validation ( ) { if ( null === $ this -> validation ) { $ this -> validation = new ValidationBuilder ( $ this ) ; } return $ this -> validation ; }
Gets the builder for validation rules .
21,943
protected function merge ( ) { if ( null === $ this -> merge ) { $ this -> merge = new MergeBuilder ( $ this ) ; } return $ this -> merge ; }
Gets the builder for merging rules .
21,944
protected function normalization ( ) { if ( null === $ this -> normalization ) { $ this -> normalization = new NormalizationBuilder ( $ this ) ; } return $ this -> normalization ; }
Gets the builder for normalization rules .
21,945
public function setPathSeparator ( string $ separator ) { if ( $ this instanceof ParentNodeDefinitionInterface ) { if ( method_exists ( $ this , 'getChildNodeDefinitions' ) ) { foreach ( $ this -> getChildNodeDefinitions ( ) as $ child ) { $ child -> setPathSeparator ( $ separator ) ; } } else { @ trigger_error ( 'Pass...
Set PathSeparator to use .
21,946
private function extract ( string $ method , array $ arguments ) { try { $ serializedArguments = serialize ( $ arguments ) ; } catch ( \ Exception $ exception ) { return $ this -> propertyInfoExtractor -> { $ method } ( ... $ arguments ) ; } $ encodedMethod = \ rawurlencode ( $ method ) ; if ( \ array_key_exists ( $ en...
Retrieves the cached data if applicable or delegates to the decorated extractor .
21,947
public static function create ( $ adapter , array $ config = [ ] ) : self { if ( ! isset ( self :: $ adapterMap [ $ adapter ] ) ) { throw new DriverNotFoundException ( sprintf ( 'Adapter "%s" not found. You should use one of: %s' , $ adapter , implode ( ', ' , self :: $ adapterMap ) ) ) ; } $ class = self :: $ adapterM...
Creates a new Ldap instance .
21,948
protected function hasSystemCallBeenInterrupted ( ) { $ lastError = $ this -> lastError ; $ this -> lastError = null ; return null !== $ lastError && false !== stripos ( $ lastError , 'interrupted system call' ) ; }
Returns true if a system call has been interrupted .
21,949
public function load ( $ class , $ type = null ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class "%s" does not exist.' , $ class ) ) ; } $ class = new \ ReflectionClass ( $ class ) ; if ( $ class -> isAbstract ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Annota...
Loads from annotations from a class .
21,950
protected function getDefaultRouteName ( \ ReflectionClass $ class , \ ReflectionMethod $ method ) { $ name = strtolower ( str_replace ( '\\' , '_' , $ class -> name ) . '_' . $ method -> name ) ; if ( $ this -> defaultRouteIndex > 0 ) { $ name .= '_' . $ this -> defaultRouteIndex ; } ++ $ this -> defaultRouteIndex ; r...
Gets the default route name for a class method .
21,951
public function dump ( DumperInterface $ dumper ) { $ refs = [ 0 ] ; $ this -> dumpItem ( $ dumper , new Cursor ( ) , $ refs , $ this -> data [ $ this -> position ] [ $ this -> key ] ) ; }
Dumps data with a DumperInterface dumper .
21,952
private function dumpChildren ( $ dumper , $ parentCursor , & $ refs , $ children , $ hashCut , $ hashType , $ dumpKeys ) { $ cursor = clone $ parentCursor ; ++ $ cursor -> depth ; $ cursor -> hashType = $ hashType ; $ cursor -> hashIndex = 0 ; $ cursor -> hashLength = \ count ( $ children ) ; $ cursor -> hashCut = $ h...
Dumps children of hash structures .
21,953
public function removeMethodCall ( $ method ) { foreach ( $ this -> calls as $ i => $ call ) { if ( $ call [ 0 ] === $ method ) { unset ( $ this -> calls [ $ i ] ) ; break ; } } return $ this ; }
Removes a method to call after service initialization .
21,954
public function hasMethodCall ( $ method ) { foreach ( $ this -> calls as $ call ) { if ( $ call [ 0 ] === $ method ) { return true ; } } return false ; }
Check if the current definition has a given method to call after service initialization .
21,955
public function setShared ( $ shared ) { $ this -> changes [ 'shared' ] = true ; $ this -> shared = ( bool ) $ shared ; return $ this ; }
Sets if the service must be shared or not .
21,956
public function setPublic ( $ boolean ) { $ this -> changes [ 'public' ] = true ; $ this -> public = ( bool ) $ boolean ; $ this -> private = false ; return $ this ; }
Sets the visibility of this service .
21,957
public function setDeprecated ( $ status = true , $ template = null ) { if ( null !== $ template ) { if ( preg_match ( '#[\r\n]|\*/#' , $ template ) ) { throw new InvalidArgumentException ( 'Invalid characters found in deprecation template.' ) ; } if ( false === strpos ( $ template , '%service_id%' ) ) { throw new Inva...
Whether this definition is deprecated that means it should not be called anymore .
21,958
public function addError ( $ error ) { if ( $ error instanceof self ) { $ this -> errors = array_merge ( $ this -> errors , $ error -> errors ) ; } else { $ this -> errors [ ] = $ error ; } return $ this ; }
Add an error that occurred when building this Definition .
21,959
public function getErrors ( ) { foreach ( $ this -> errors as $ i => $ error ) { if ( $ error instanceof \ Closure ) { $ this -> errors [ $ i ] = ( string ) $ error ( ) ; } elseif ( ! \ is_string ( $ error ) ) { $ this -> errors [ $ i ] = ( string ) $ error ; } } return $ this -> errors ; }
Returns any errors that occurred while building this Definition .
21,960
private function getTraces ( RequestDataCollector $ request , string $ method ) : array { $ traceRequest = Request :: create ( $ request -> getPathInfo ( ) , $ request -> getRequestServer ( true ) -> get ( 'REQUEST_METHOD' ) , [ ] , $ request -> getRequestCookies ( true ) -> all ( ) , [ ] , $ request -> getRequestServe...
Returns the routing traces associated to the given request .
21,961
protected function flatten ( \ ResourceBundle $ rb , array & $ messages = [ ] , $ path = null ) { foreach ( $ rb as $ key => $ value ) { $ nodePath = $ path ? $ path . '.' . $ key : $ key ; if ( $ value instanceof \ ResourceBundle ) { $ this -> flatten ( $ value , $ messages , $ nodePath ) ; } else { $ messages [ $ nod...
Flattens an ResourceBundle .
21,962
public function reverseTransform ( $ value ) { if ( null === $ value ) { return ; } if ( ! is_numeric ( $ value ) ) { throw new TransformationFailedException ( 'Expected a numeric.' ) ; } try { $ dateTime = new \ DateTime ( ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( $ this -> outputTimezone ) ) ; $ dateTime -...
Transforms a timestamp in the configured timezone into a DateTime object .
21,963
public static function setError ( $ code , $ message = '' ) { if ( ! isset ( self :: $ errorCodes [ $ code ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No such error code: "%s"' , $ code ) ) ; } self :: $ errorMessage = $ message ? sprintf ( '%s: %s' , $ message , self :: $ errorCodes [ $ code ] ) : self :...
Sets the current error .
21,964
public function addVoterVote ( VoterInterface $ voter , array $ attributes , int $ vote ) { $ currentLogIndex = \ count ( $ this -> currentLog ) - 1 ; $ this -> currentLog [ $ currentLogIndex ] [ 'voterDetails' ] [ ] = [ 'voter' => $ voter , 'attributes' => $ attributes , 'vote' => $ vote , ] ; }
Adds voter vote and class to the voter details .
21,965
private function readLong ( $ stream , bool $ isBigEndian ) : int { $ result = unpack ( $ isBigEndian ? 'N1' : 'V1' , fread ( $ stream , 4 ) ) ; $ result = current ( $ result ) ; return ( int ) substr ( $ result , - 8 ) ; }
Reads an unsigned long from stream respecting endianness .
21,966
private function attemptSwitchUser ( Request $ request , $ username ) { $ token = $ this -> tokenStorage -> getToken ( ) ; $ originalToken = $ this -> getOriginalToken ( $ token ) ; if ( null !== $ originalToken ) { if ( $ token -> getUsername ( ) === $ username ) { return $ token ; } throw new \ LogicException ( sprin...
Attempts to switch to another user .
21,967
private function attemptExitUser ( Request $ request ) { if ( null === ( $ currentToken = $ this -> tokenStorage -> getToken ( ) ) || null === $ original = $ this -> getOriginalToken ( $ currentToken ) ) { throw new AuthenticationCredentialsNotFoundException ( 'Could not find original Token object.' ) ; } if ( null !==...
Attempts to exit from an already switched user .
21,968
public function import ( $ resource , $ prefix = '/' , $ type = null ) { $ collections = $ this -> load ( $ resource , $ type ) ; $ builder = $ this -> createBuilder ( ) ; foreach ( $ collections as $ collection ) { if ( null === $ collection ) { continue ; } foreach ( $ collection -> all ( ) as $ name => $ route ) { $...
Import an external routing resource and returns the RouteCollectionBuilder .
21,969
public function add ( $ path , $ controller , $ name = null ) { $ route = new Route ( $ path ) ; $ route -> setDefault ( '_controller' , $ controller ) ; $ this -> addRoute ( $ route , $ name ) ; return $ route ; }
Adds a route and returns it for future modification .
21,970
public function mount ( $ prefix , self $ builder ) { $ builder -> prefix = trim ( trim ( $ prefix ) , '/' ) ; $ this -> routes [ ] = $ builder ; }
Add a RouteCollectionBuilder .
21,971
public function addRoute ( Route $ route , $ name = null ) { if ( null === $ name ) { $ name = '_unnamed_route_' . spl_object_hash ( $ route ) ; } $ this -> routes [ $ name ] = $ route ; return $ this ; }
Adds a Route object to the builder .
21,972
public function build ( ) { $ routeCollection = new RouteCollection ( ) ; foreach ( $ this -> routes as $ name => $ route ) { if ( $ route instanceof Route ) { $ route -> setDefaults ( array_merge ( $ this -> defaults , $ route -> getDefaults ( ) ) ) ; $ route -> setOptions ( array_merge ( $ this -> options , $ route -...
Creates the final RouteCollection and returns it .
21,973
private function generateRouteName ( Route $ route ) : string { $ methods = implode ( '_' , $ route -> getMethods ( ) ) . '_' ; $ routeName = $ methods . $ route -> getPath ( ) ; $ routeName = str_replace ( [ '/' , ':' , '|' , '-' ] , '_' , $ routeName ) ; $ routeName = preg_replace ( '/[^a-z0-9A-Z_.]+/' , '' , $ route...
Generates a route name based on details of this route .
21,974
private function load ( $ resource , string $ type = null ) : array { if ( null === $ this -> loader ) { throw new \ BadMethodCallException ( 'Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.' ) ; } if ( $ this -> loader -> supports ( $ resource , $ type )...
Finds a loader able to load an imported resource and loads it .
21,975
public function getProfile ( ) { if ( ! $ this -> kernel -> getContainer ( ) -> has ( 'profiler' ) ) { return false ; } return $ this -> kernel -> getContainer ( ) -> get ( 'profiler' ) -> loadProfileFromResponse ( $ this -> response ) ; }
Gets the profile associated with the current Response .
21,976
public function setDefaultLogger ( LoggerInterface $ logger , $ levels = E_ALL , $ replace = false ) { $ loggers = [ ] ; if ( \ is_array ( $ levels ) ) { foreach ( $ levels as $ type => $ logLevel ) { if ( empty ( $ this -> loggers [ $ type ] [ 0 ] ) || $ replace || $ this -> loggers [ $ type ] [ 0 ] === $ this -> boot...
Sets a logger to non assigned errors levels .
21,977
public function setLoggers ( array $ loggers ) { $ prevLogged = $ this -> loggedErrors ; $ prev = $ this -> loggers ; $ flush = [ ] ; foreach ( $ loggers as $ type => $ log ) { if ( ! isset ( $ prev [ $ type ] ) ) { throw new \ InvalidArgumentException ( 'Unknown error type: ' . $ type ) ; } if ( ! \ is_array ( $ log )...
Sets a logger for each error level .
21,978
public function throwAt ( $ levels , $ replace = false ) { $ prev = $ this -> thrownErrors ; $ this -> thrownErrors = ( $ levels | E_RECOVERABLE_ERROR | E_USER_ERROR ) & ~ E_USER_DEPRECATED & ~ E_DEPRECATED ; if ( ! $ replace ) { $ this -> thrownErrors |= $ prev ; } $ this -> reRegister ( $ prev | $ this -> loggedError...
Sets the PHP error levels that throw an exception when a PHP error occurs .
21,979
public function scopeAt ( $ levels , $ replace = false ) { $ prev = $ this -> scopedErrors ; $ this -> scopedErrors = ( int ) $ levels ; if ( ! $ replace ) { $ this -> scopedErrors |= $ prev ; } return $ prev ; }
Sets the PHP error levels for which local variables are preserved .
21,980
public function traceAt ( $ levels , $ replace = false ) { $ prev = $ this -> tracedErrors ; $ this -> tracedErrors = ( int ) $ levels ; if ( ! $ replace ) { $ this -> tracedErrors |= $ prev ; } return $ prev ; }
Sets the PHP error levels for which the stack trace is preserved .
21,981
private function reRegister ( $ prev ) { if ( $ prev !== $ this -> thrownErrors | $ this -> loggedErrors ) { $ handler = set_error_handler ( 'var_dump' ) ; $ handler = \ is_array ( $ handler ) ? $ handler [ 0 ] : null ; restore_error_handler ( ) ; if ( $ handler === $ this ) { restore_error_handler ( ) ; if ( $ this ->...
Re - registers as a PHP error handler if levels changed .
21,982
private function cleanTrace ( $ backtrace , $ type , $ file , $ line , $ throw ) { $ lightTrace = $ backtrace ; for ( $ i = 0 ; isset ( $ backtrace [ $ i ] ) ; ++ $ i ) { if ( isset ( $ backtrace [ $ i ] [ 'file' ] , $ backtrace [ $ i ] [ 'line' ] ) && $ backtrace [ $ i ] [ 'line' ] === $ line && $ backtrace [ $ i ] [ ...
Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader .
21,983
public static function checkTime ( $ hour , $ minute , $ second ) { return $ hour >= 0 && $ hour < 24 && $ minute >= 0 && $ minute < 60 && $ second >= 0 && $ second < 60 ; }
Checks whether a time is valid .
21,984
protected function padLeft ( string $ value , int $ length ) : string { return str_pad ( $ value , $ length , '0' , STR_PAD_LEFT ) ; }
Pad a string with zeros to the left .
21,985
protected function getScript ( $ request ) { $ kernel = var_export ( serialize ( $ this -> kernel ) , true ) ; $ request = var_export ( serialize ( $ request ) , true ) ; $ errorReporting = error_reporting ( ) ; $ requires = '' ; foreach ( get_declared_classes ( ) as $ class ) { if ( 0 === strpos ( $ class , 'ComposerA...
Returns the script to execute when the request must be insulated .
21,986
protected function filterFiles ( array $ files ) { $ filtered = [ ] ; foreach ( $ files as $ key => $ value ) { if ( \ is_array ( $ value ) ) { $ filtered [ $ key ] = $ this -> filterFiles ( $ value ) ; } elseif ( $ value instanceof UploadedFile ) { if ( $ value -> isValid ( ) && $ value -> getSize ( ) > UploadedFile :...
Filters an array of files .
21,987
protected function filterResponse ( $ response ) { ob_start ( ) ; $ response -> sendContent ( ) ; $ content = ob_get_clean ( ) ; return new DomResponse ( $ content , $ response -> getStatusCode ( ) , $ response -> headers -> all ( ) ) ; }
Converts the HttpKernel response to a BrowserKit response .
21,988
protected function initializeBundles ( ) { $ this -> bundles = [ ] ; foreach ( $ this -> registerBundles ( ) as $ bundle ) { $ name = $ bundle -> getName ( ) ; if ( isset ( $ this -> bundles [ $ name ] ) ) { throw new \ LogicException ( sprintf ( 'Trying to register two bundles with the same name "%s"' , $ name ) ) ; }...
Initializes bundles .
21,989
public function process ( ContainerBuilder $ container ) { $ graph = $ container -> getCompiler ( ) -> getServiceReferenceGraph ( ) ; $ this -> checkedNodes = [ ] ; foreach ( $ graph -> getNodes ( ) as $ id => $ node ) { $ this -> currentPath = [ $ id ] ; $ this -> checkOutEdges ( $ node -> getOutEdges ( ) ) ; } }
Checks the ContainerBuilder object for circular references .
21,990
private function checkOutEdges ( array $ edges ) { foreach ( $ edges as $ edge ) { $ node = $ edge -> getDestNode ( ) ; $ id = $ node -> getId ( ) ; if ( empty ( $ this -> checkedNodes [ $ id ] ) ) { if ( ! $ node -> getValue ( ) || ( ! $ edge -> isLazy ( ) && ! $ edge -> isWeak ( ) ) ) { $ searchKey = array_search ( $...
Checks for circular references .
21,991
public function getExtension ( $ name ) { if ( isset ( $ this -> extensions [ $ name ] ) ) { return $ this -> extensions [ $ name ] ; } if ( isset ( $ this -> extensionsByNs [ $ name ] ) ) { return $ this -> extensionsByNs [ $ name ] ; } throw new LogicException ( sprintf ( 'Container extension "%s" is not registered' ...
Returns an extension by alias or namespace .
21,992
public function hasExtension ( $ name ) { return isset ( $ this -> extensions [ $ name ] ) || isset ( $ this -> extensionsByNs [ $ name ] ) ; }
Checks if we have an extension .
21,993
public function addObjectResource ( $ object ) { if ( $ this -> trackResources ) { if ( \ is_object ( $ object ) ) { $ object = \ get_class ( $ object ) ; } if ( ! isset ( $ this -> classReflectors [ $ object ] ) ) { $ this -> classReflectors [ $ object ] = new \ ReflectionClass ( $ object ) ; } $ class = $ this -> cla...
Adds the object class hierarchy as resources .
21,994
public function getExtensionConfig ( $ name ) { if ( ! isset ( $ this -> extensionConfigs [ $ name ] ) ) { $ this -> extensionConfigs [ $ name ] = [ ] ; } return $ this -> extensionConfigs [ $ name ] ; }
Returns the configuration array for the given extension .
21,995
public function prependExtensionConfig ( $ name , array $ config ) { if ( ! isset ( $ this -> extensionConfigs [ $ name ] ) ) { $ this -> extensionConfigs [ $ name ] = [ ] ; } array_unshift ( $ this -> extensionConfigs [ $ name ] , $ config ) ; }
Prepends a config array to the configs of the given extension .
21,996
public function addAliases ( array $ aliases ) { foreach ( $ aliases as $ alias => $ id ) { $ this -> setAlias ( $ alias , $ id ) ; } }
Adds the service aliases .
21,997
public function addDefinitions ( array $ definitions ) { foreach ( $ definitions as $ id => $ definition ) { $ this -> setDefinition ( $ id , $ definition ) ; } }
Adds the service definitions .
21,998
public function findTags ( ) { $ tags = [ ] ; foreach ( $ this -> getDefinitions ( ) as $ id => $ definition ) { $ tags = array_merge ( array_keys ( $ definition -> getTags ( ) ) , $ tags ) ; } return array_unique ( $ tags ) ; }
Returns all tags the defined services use .
21,999
public function registerAliasForArgument ( string $ id , string $ type , string $ name = null ) : Alias { $ name = lcfirst ( str_replace ( ' ' , '' , ucwords ( preg_replace ( '/[^a-zA-Z0-9\x7f-\xff]++/' , ' ' , $ name ?? $ id ) ) ) ) ; if ( ! preg_match ( '/^[a-zA-Z_\x7f-\xff]/' , $ name ) ) { throw new InvalidArgument...
Registers an autowiring alias that only binds to a specific argument name .