idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
3,400 | public static function isMobileOnlyBrowser ( $ browser ) { return in_array ( $ browser , self :: $ mobileOnlyBrowsers ) || ( in_array ( $ browser , self :: $ availableBrowsers ) && in_array ( array_search ( $ browser , self :: $ availableBrowsers ) , self :: $ mobileOnlyBrowsers ) ) ; } | Returns if the given browser is mobile only |
3,401 | public function parse ( ) { $ result = null ; if ( $ this -> preMatchOverall ( ) ) { foreach ( $ this -> getRegexes ( ) as $ regex ) { $ matches = $ this -> matchUserAgent ( $ regex [ 'regex' ] ) ; if ( $ matches ) { $ result = array ( 'type' => $ this -> parserName , 'name' => $ this -> buildByMatch ( $ regex [ 'name'... | Parses the current UA and checks whether it contains any client information |
3,402 | public static function getAvailableClients ( ) { $ instance = new static ( ) ; $ regexes = $ instance -> getRegexes ( ) ; $ names = array ( ) ; foreach ( $ regexes as $ regex ) { if ( $ regex [ 'name' ] != '$1' ) { $ names [ ] = $ regex [ 'name' ] ; } } natcasesort ( $ names ) ; return array_unique ( $ names ) ; } | Returns all names defined in the regexes |
3,403 | public function parse ( ) { $ result = null ; if ( $ this -> preMatchOverall ( ) ) { if ( $ this -> discardDetails ) { $ result = true ; } else { foreach ( $ this -> getRegexes ( ) as $ regex ) { $ matches = $ this -> matchUserAgent ( $ regex [ 'regex' ] ) ; if ( $ matches ) { unset ( $ regex [ 'regex' ] ) ; $ result =... | Parses the current UA and checks whether it contains bot information |
3,404 | public static function getOsFamily ( $ osLabel ) { foreach ( self :: $ osFamilies as $ family => $ labels ) { if ( in_array ( $ osLabel , $ labels ) ) { return $ family ; } } return false ; } | Returns the operating system family for the given operating system |
3,405 | public static function getNameFromId ( $ os , $ ver = false ) { if ( array_key_exists ( $ os , self :: $ operatingSystems ) ) { $ osFullName = self :: $ operatingSystems [ $ os ] ; return trim ( $ osFullName . " " . $ ver ) ; } return false ; } | Returns the full name for the given short name |
3,406 | public static function setVersionTruncation ( $ type ) { if ( in_array ( $ type , array ( self :: VERSION_TRUNCATION_BUILD , self :: VERSION_TRUNCATION_NONE , self :: VERSION_TRUNCATION_MAJOR , self :: VERSION_TRUNCATION_MINOR , self :: VERSION_TRUNCATION_PATCH ) ) ) { self :: $ maxMinorParts = $ type ; } } | Set how DeviceDetector should return versions |
3,407 | protected function matchUserAgent ( $ regex ) { $ regex = '/(?:^|[^A-Z0-9\-_]|[^A-Z0-9\-]_|sprd-)(?:' . str_replace ( '/' , '\/' , $ regex ) . ')/i' ; if ( preg_match ( $ regex , $ this -> userAgent , $ matches ) ) { return $ matches ; } return false ; } | Matches the useragent against the given regex |
3,408 | protected function preMatchOverall ( ) { $ regexes = $ this -> getRegexes ( ) ; static $ overAllMatch ; $ cacheKey = $ this -> parserName . DeviceDetector :: VERSION . '-all' ; $ cacheKey = preg_replace ( '/([^a-z0-9_-]+)/i' , '' , $ cacheKey ) ; if ( empty ( $ overAllMatch ) ) { $ overAllMatch = $ this -> getCache ( )... | Tests the useragent against a combination of all regexes |
3,409 | public static function for ( $ baseQuery , ? Request $ request = null ) : self { if ( is_string ( $ baseQuery ) ) { $ baseQuery = ( $ baseQuery ) :: query ( ) ; } return new static ( $ baseQuery , $ request ?? request ( ) ) ; } | Create a new QueryBuilder for a request and model . |
3,410 | private function bootstrapApplicationEnvironment ( $ appBootstrap , $ appenv , $ debug ) { $ appBootstrap = $ this -> normalizeBootstrapClass ( $ appBootstrap ) ; $ this -> middleware = new $ appBootstrap ; if ( $ this -> middleware instanceof ApplicationEnvironmentAwareInterface ) { $ this -> middleware -> initialize ... | Bootstrap application environment |
3,411 | public function add ( Slave $ slave ) { $ port = $ slave -> getPort ( ) ; if ( isset ( $ this -> slaves [ $ port ] ) ) { throw new \ Exception ( "Slave port $port already occupied." ) ; } if ( $ slave -> getPort ( ) !== $ port ) { throw new \ Exception ( "Slave mis-assigned." ) ; } $ this -> slaves [ $ port ] = $ slave... | Add slave to pool |
3,412 | public function remove ( Slave $ slave ) { $ port = $ slave -> getPort ( ) ; $ this -> getByPort ( $ port ) ; unset ( $ this -> slaves [ $ port ] ) ; } | Remove from pool |
3,413 | public function getByPort ( $ port ) { if ( ! isset ( $ this -> slaves [ $ port ] ) ) { throw new \ Exception ( "Slave port $port empty." ) ; } return $ this -> slaves [ $ port ] ; } | Get slave by port |
3,414 | public function getByConnection ( ConnectionInterface $ connection ) { $ hash = spl_object_hash ( $ connection ) ; foreach ( $ this -> slaves as $ slave ) { if ( $ slave -> getConnection ( ) && $ hash === spl_object_hash ( $ slave -> getConnection ( ) ) ) { return $ slave ; } } throw new \ Exception ( "Slave connection... | Get slave slaves by connection |
3,415 | public function getByStatus ( $ status ) { return array_filter ( $ this -> slaves , function ( $ slave ) use ( $ status ) { return $ status === Slave :: ANY || $ status === $ slave -> getStatus ( ) ; } ) ; } | Get multiple slaves by status |
3,416 | public function getStatusSummary ( ) { $ map = [ 'total' => Slave :: ANY , 'ready' => Slave :: READY , 'busy' => Slave :: BUSY , 'created' => Slave :: CREATED , 'registered' => Slave :: REGISTERED , 'closed' => Slave :: CLOSED ] ; return array_map ( function ( $ state ) { return count ( $ this -> getByStatus ( $ state ... | Return a human - readable summary of the slaves in the pool . |
3,417 | public function register ( $ pid , ConnectionInterface $ connection ) { if ( $ this -> status !== self :: CREATED ) { throw new \ LogicException ( 'Cannot register a slave that is not in created state' ) ; } $ this -> pid = $ pid ; $ this -> connection = $ connection ; $ this -> status = self :: REGISTERED ; } | Register a slave after it s process started |
3,418 | public function ready ( ) { if ( $ this -> status !== self :: REGISTERED ) { throw new \ LogicException ( 'Cannot ready a slave that is not in registered state' ) ; } $ this -> status = self :: READY ; } | Ready a slave after bootstrap completed |
3,419 | public function occupy ( ) { if ( $ this -> status !== self :: READY ) { throw new \ LogicException ( 'Cannot occupy a slave that is not in ready state' ) ; } $ this -> status = self :: BUSY ; } | Occupies a slave for request handling |
3,420 | public function release ( ) { if ( $ this -> status !== self :: BUSY ) { throw new \ LogicException ( 'Cannot release a slave that is not in busy state' ) ; } $ this -> status = self :: READY ; $ this -> handledRequests ++ ; } | Releases a slave from request handling |
3,421 | public function handle ( ConnectionInterface $ incoming ) { $ this -> incoming = $ incoming ; $ this -> incoming -> on ( 'data' , [ $ this , 'handleData' ] ) ; $ this -> incoming -> on ( 'close' , function ( ) { $ this -> connectionOpen = false ; } ) ; $ this -> start = microtime ( true ) ; $ this -> requestSentAt = mi... | Handle incoming client connection |
3,422 | public function handleData ( $ data ) { $ this -> incomingBuffer .= $ data ; if ( $ this -> connection && $ this -> isHeaderEnd ( $ this -> incomingBuffer ) ) { $ remoteAddress = ( string ) $ this -> incoming -> getRemoteAddress ( ) ; $ headersToReplace = [ 'X-PHP-PM-Remote-IP' => trim ( parse_url ( $ remoteAddress , P... | Buffer incoming data until slave connection is available and headers have been received |
3,423 | public function getNextSlave ( ) { if ( ! $ this -> connectionOpen ) { return ; } $ available = $ this -> slaves -> getByStatus ( Slave :: READY ) ; if ( count ( $ available ) ) { $ slave = array_shift ( $ available ) ; if ( $ this -> tryOccupySlave ( $ slave ) ) { return ; } } if ( time ( ) < ( $ this -> requestSentAt... | Get next free slave from pool Asynchronously keep trying until slave becomes available |
3,424 | public function tryOccupySlave ( Slave $ slave ) { if ( $ slave -> isExpired ( ) ) { $ slave -> close ( ) ; $ this -> output -> writeln ( sprintf ( 'Restart worker #%d because it reached its TTL' , $ slave -> getPort ( ) ) ) ; $ slave -> getConnection ( ) -> close ( ) ; return false ; } $ this -> redirectionTries ++ ; ... | Slave available handler |
3,425 | public function slaveConnected ( ConnectionInterface $ connection ) { $ this -> connection = $ connection ; $ this -> verboseTimer ( function ( $ took ) { return sprintf ( '<info>Took abnormal %.3f seconds for connecting to worker %d</info>' , $ took , $ this -> slave -> getPort ( ) ) ; } ) ; $ this -> handleData ( '' ... | Handle successful slave connection |
3,426 | public function maxExecutionTimeExceeded ( ) { if ( ! $ this -> connectionOpen ) { return false ; } $ this -> incoming -> write ( $ this -> createErrorResponse ( '504 Gateway Timeout' , 'Maximum execution time exceeded' ) ) ; $ this -> lastOutgoingData = 'not empty' ; $ this -> slave -> close ( ) ; $ this -> output -> ... | Stop the worker if the max execution time has been exceeded and return 504 |
3,427 | public function slaveClosed ( ) { $ this -> verboseTimer ( function ( $ took ) { return sprintf ( '<info>Worker %d took abnormal %.3f seconds for handling a connection</info>' , $ this -> slave -> getPort ( ) , $ took ) ; } ) ; if ( $ this -> lastOutgoingData == '' ) { $ this -> output -> writeln ( 'Script did not retu... | Handle slave disconnected |
3,428 | public function slaveConnectFailed ( \ Exception $ e ) { $ this -> slave -> release ( ) ; $ this -> verboseTimer ( function ( $ took ) use ( $ e ) { return sprintf ( '<error>Connection to worker %d failed. Try #%d, took %.3fs ' . '(timeout %ds). Error message: [%d] %s</error>' , $ this -> slave -> getPort ( ) , $ this ... | Handle failed slave connection |
3,429 | protected function verboseTimer ( $ callback , $ always = false ) { $ took = microtime ( true ) - $ this -> start ; if ( ( $ always || $ took > 1 ) && $ this -> output -> isVeryVerbose ( ) ) { $ message = $ callback ( $ took ) ; $ this -> output -> writeln ( $ message ) ; } $ this -> start = microtime ( true ) ; } | Section timer . Measure execution time hand output if verbose mode . |
3,430 | protected function replaceHeader ( $ header , $ headersToReplace ) { $ result = $ header ; foreach ( $ headersToReplace as $ key => $ value ) { if ( false !== $ headerPosition = stripos ( $ result , $ key . ':' ) ) { $ length = strpos ( substr ( $ header , $ headerPosition ) , "\r\n" ) ; $ result = substr_replace ( $ r... | Replaces or injects header |
3,431 | public function prepareShutdown ( ) { if ( $ this -> inShutdown ) { return false ; } if ( $ this -> errorLogger && $ logs = $ this -> errorLogger -> cleanLogs ( ) ) { $ messages = array_map ( function ( $ item ) { $ message = $ item [ 1 ] ; $ context = $ item [ 2 ] ; if ( isset ( $ context [ 'file' ] ) ) { $ message .=... | Shuts down the event loop . This basically exits the process . |
3,432 | protected function bootstrap ( $ appBootstrap , $ appenv , $ debug ) { if ( $ bridge = $ this -> getBridge ( ) ) { $ bridge -> bootstrap ( $ appBootstrap , $ appenv , $ debug ) ; $ this -> sendMessage ( $ this -> controller , 'ready' ) ; } } | Bootstraps the actual application . |
3,433 | protected function sendCurrentFiles ( ) { if ( ! $ this -> isDebug ( ) ) { return ; } $ files = array_merge ( $ this -> watchedFiles , get_included_files ( ) ) ; $ flipped = array_flip ( $ files ) ; if ( ! $ this -> lastSentFiles || array_diff_key ( $ flipped , $ this -> lastSentFiles ) ) { $ this -> lastSentFiles = $ ... | Sends to the master a snapshot of current known php files so it can track those files and restart slaves if necessary . |
3,434 | private function doConnect ( ) { $ connector = new UnixConnector ( $ this -> loop ) ; $ unixSocket = $ this -> getControllerSocketPath ( false ) ; $ connector -> connect ( $ unixSocket ) -> done ( function ( $ controller ) { $ this -> controller = $ controller ; $ this -> loop -> addSignal ( SIGTERM , [ $ this , 'shutd... | Attempt a connection to the unix socket . |
3,435 | public function run ( ) { $ this -> loop = Factory :: create ( ) ; $ this -> errorLogger = BufferingLogger :: create ( ) ; ErrorHandler :: register ( new ErrorHandler ( $ this -> errorLogger ) ) ; $ this -> tryConnect ( ) ; $ this -> loop -> run ( ) ; } | Connects to ProcessManager master process . |
3,436 | protected function handleRequest ( ServerRequestInterface $ request ) { if ( $ this -> getStaticDirectory ( ) ) { $ staticResponse = $ this -> serveStatic ( $ request ) ; if ( $ staticResponse instanceof ResponseInterface ) { return $ staticResponse ; } } if ( $ bridge = $ this -> getBridge ( ) ) { try { $ response = $... | Handle a redirected request from master . |
3,437 | public function shutdown ( $ graceful = true ) { if ( $ this -> status === self :: STATE_SHUTDOWN ) { return ; } $ this -> output -> writeln ( "<info>Server is shutting down.</info>" ) ; $ this -> status = self :: STATE_SHUTDOWN ; $ remainingSlaves = count ( $ this -> slaves -> getByStatus ( Slave :: READY ) ) ; if ( $... | Handles termination signals so we can gracefully stop all servers . |
3,438 | private function quit ( ) { $ this -> output -> writeln ( 'Stopping the process manager.' ) ; if ( $ this -> controller ) { @ $ this -> controller -> close ( ) ; } if ( $ this -> web ) { @ $ this -> web -> close ( ) ; } if ( $ this -> loop ) { $ this -> loop -> stop ( ) ; } unlink ( $ this -> pidfile ) ; exit ; } | To be called after all workers have been terminated and the event loop is no longer in use . |
3,439 | public function run ( ) { Debug :: enable ( ) ; ini_set ( 'zlib.output_compression' , 0 ) ; ini_set ( 'output_buffering' , 0 ) ; ini_set ( 'implicit_flush' , 1 ) ; ob_implicit_flush ( 1 ) ; $ this -> loop = Factory :: create ( ) ; $ this -> controller = new UnixServer ( $ this -> getControllerSocketPath ( ) , $ this ->... | Starts the main loop . Blocks . |
3,440 | public function onSlaveConnection ( ConnectionInterface $ connection ) { $ this -> bindProcessMessage ( $ connection ) ; $ connection -> on ( 'close' , function ( ) use ( $ connection ) { $ this -> onSlaveClosed ( $ connection ) ; } ) ; } | Handles data communication from slave - > master |
3,441 | public function onSlaveClosed ( ConnectionInterface $ connection ) { if ( $ this -> status === self :: STATE_SHUTDOWN ) { return ; } try { $ slave = $ this -> slaves -> getByConnection ( $ connection ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( '<error>Worker permanently closed during PHP-PM bootstra... | Handle slave closed |
3,442 | protected function commandStatus ( array $ data , ConnectionInterface $ conn ) { $ conn -> removeAllListeners ( 'close' ) ; if ( $ this -> output -> isVeryVerbose ( ) ) { $ conn -> on ( 'close' , function ( ) { $ this -> output -> writeln ( 'Status command requested' ) ; } ) ; } $ requests = array_reduce ( $ this -> sl... | A slave sent a status command . |
3,443 | protected function commandStop ( array $ data , ConnectionInterface $ conn ) { if ( $ this -> output -> isVeryVerbose ( ) ) { $ conn -> on ( 'close' , function ( ) { $ this -> output -> writeln ( 'Stop command requested' ) ; } ) ; } $ conn -> end ( json_encode ( [ ] ) ) ; $ this -> shutdown ( ) ; } | A slave sent a stop command . |
3,444 | protected function commandReload ( array $ data , ConnectionInterface $ conn ) { $ conn -> removeAllListeners ( 'close' ) ; if ( $ this -> output -> isVeryVerbose ( ) ) { $ conn -> on ( 'close' , function ( ) { $ this -> output -> writeln ( 'Reload command requested' ) ; } ) ; } $ conn -> end ( json_encode ( [ ] ) ) ; ... | A slave sent a reload command . |
3,445 | protected function commandRegister ( array $ data , ConnectionInterface $ conn ) { $ pid = ( int ) $ data [ 'pid' ] ; $ port = ( int ) $ data [ 'port' ] ; try { $ slave = $ this -> slaves -> getByPort ( $ port ) ; $ slave -> register ( $ pid , $ conn ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( sprin... | A slave sent a register command . |
3,446 | protected function commandReady ( array $ data , ConnectionInterface $ conn ) { try { $ slave = $ this -> slaves -> getByConnection ( $ conn ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( '<error>A ready command was sent by a worker with no connection. This was unexpected. ' . 'Not your fault, please c... | A slave sent a ready commands which basically says that the slave bootstrapped successfully the application and is ready to accept connections . |
3,447 | protected function commandFiles ( array $ data , ConnectionInterface $ conn ) { try { $ slave = $ this -> slaves -> getByConnection ( $ conn ) ; $ start = microtime ( true ) ; clearstatcache ( ) ; $ newFilesCount = 0 ; $ knownFiles = array_keys ( $ this -> filesLastMTime ) ; $ recentlyIncludedFiles = array_diff ( $ dat... | Register client files for change tracking |
3,448 | protected function commandStats ( array $ data , ConnectionInterface $ conn ) { try { $ slave = $ this -> slaves -> getByConnection ( $ conn ) ; $ slave -> setUsedMemory ( $ data [ 'memory_usage' ] ) ; if ( $ this -> output -> isVeryVerbose ( ) ) { $ this -> output -> writeln ( sprintf ( 'Current memory usage for worke... | Receive stats from the worker such as current memory use |
3,449 | protected function bootstrapFailed ( $ port ) { if ( $ this -> isDebug ( ) ) { $ this -> output -> writeln ( '' ) ; if ( $ this -> status !== self :: STATE_EMERGENCY ) { $ this -> status = self :: STATE_EMERGENCY ; $ this -> output -> writeln ( sprintf ( '<error>Application bootstrap failed. We are entering emergency m... | Handles failed application bootstraps . |
3,450 | protected function checkChangedFiles ( $ restartSlaves = true ) { if ( $ this -> inChangesDetectionCycle ) { return false ; } $ start = microtime ( true ) ; $ hasChanged = false ; $ this -> inChangesDetectionCycle = true ; clearstatcache ( ) ; foreach ( $ this -> filesLastMTime as $ filePath => $ knownMTime ) { if ( ! ... | Checks if tracked files have changed . If so restart all slaves . |
3,451 | public function createSlaves ( ) { for ( $ i = 1 ; $ i <= $ this -> slaveCount ; $ i ++ ) { $ this -> newSlaveInstance ( self :: CONTROLLER_PORT + $ i ) ; } } | Populate slave pool |
3,452 | protected function closeSlave ( $ slave ) { $ slave -> close ( ) ; $ this -> slaves -> remove ( $ slave ) ; if ( ! empty ( $ slave -> getConnection ( ) ) ) { $ connection = $ slave -> getConnection ( ) ; $ connection -> removeAllListeners ( 'close' ) ; $ connection -> close ( ) ; } } | Close a slave |
3,453 | public function reloadSlaves ( $ graceful = true ) { $ this -> output -> writeln ( '<info>Reloading all workers gracefully</info>' ) ; $ this -> closeSlaves ( $ graceful , function ( $ slave ) { if ( $ this -> output -> isVeryVerbose ( ) ) { $ this -> output -> writeln ( sprintf ( 'Worker #%d has been closed, reloading... | Reload slaves in - place allowing busy workers to finish what they are doing . |
3,454 | public function closeSlaves ( $ graceful = false , $ onSlaveClosed = null ) { if ( ! $ onSlaveClosed ) { $ onSlaveClosed = function ( $ slave ) { } ; } $ this -> slavesToReload = [ ] ; foreach ( $ this -> slaves -> getByStatus ( Slave :: ANY ) as $ slave ) { $ connection = $ slave -> getConnection ( ) ; if ( $ connecti... | Closes all slaves and fires a user - defined callback for each slave that is closed . |
3,455 | public function restartSlaves ( ) { if ( $ this -> inRestart ) { return ; } $ this -> inRestart = true ; $ this -> closeSlaves ( ) ; $ this -> createSlaves ( ) ; $ this -> inRestart = false ; } | Restart all slaves . Necessary when watched files have changed . |
3,456 | protected function allSlavesReady ( ) { if ( $ this -> status === self :: STATE_STARTING || $ this -> status === self :: STATE_EMERGENCY ) { $ readySlaves = $ this -> slaves -> getByStatus ( Slave :: READY ) ; $ busySlaves = $ this -> slaves -> getByStatus ( Slave :: BUSY ) ; return count ( $ readySlaves ) + count ( $ ... | Check if all slaves have become available |
3,457 | protected function newSlaveInstance ( $ port ) { if ( $ this -> status === self :: STATE_SHUTDOWN ) { return ; } if ( $ this -> output -> isVeryVerbose ( ) ) { $ this -> output -> writeln ( sprintf ( "Start new worker #%d" , $ port ) ) ; } $ socketpath = var_export ( $ this -> getSocketPath ( ) , true ) ; $ bridge = va... | Creates a new ProcessSlave instance . |
3,458 | protected function addLookupsForNestedProperty ( string $ property , Builder $ aggregationBuilder , string $ resourceClass ) : array { $ propertyParts = $ this -> splitPropertyParts ( $ property , $ resourceClass ) ; $ alias = '' ; foreach ( $ propertyParts [ 'associations' ] as $ association ) { $ classMetadata = $ th... | Adds the necessary lookups for a nested property . |
3,459 | private function formatWhitelist ( array $ whitelist ) : array { if ( array_values ( $ whitelist ) === $ whitelist ) { return $ whitelist ; } foreach ( $ whitelist as $ name => $ value ) { if ( null === $ value ) { unset ( $ whitelist [ $ name ] ) ; $ whitelist [ ] = $ name ; } } return $ whitelist ; } | Generate an array of whitelist properties to match the format that properties will have in the request . |
3,460 | private function populateIdentifier ( array $ data , string $ class ) : array { $ identifier = $ this -> identifierExtractor -> getIdentifierFromResourceClass ( $ class ) ; $ identifier = null === $ this -> nameConverter ? $ identifier : $ this -> nameConverter -> normalize ( $ identifier , $ class , self :: FORMAT ) ;... | Populates the resource identifier with the document identifier if not present in the original JSON document . |
3,461 | protected function getPaginationConfig ( $ object , array $ context = [ ] ) : array { $ currentPage = $ lastPage = $ itemsPerPage = $ pageTotalItems = $ totalItems = null ; $ paginated = $ paginator = false ; if ( $ object instanceof PartialPaginatorInterface ) { $ paginated = $ paginator = true ; if ( $ object instanc... | Gets the pagination configuration . |
3,462 | private function getProperties ( string $ className , int $ specVersion = 2 ) : stdClass { return $ this -> getClassInfo ( $ className , $ specVersion ) -> { 'properties' } ?? new \ stdClass ( ) ; } | Gets all operations of a given class . |
3,463 | private function getLastJsonResponse ( ) : stdClass { if ( null === ( $ decoded = json_decode ( $ this -> restContext -> getMink ( ) -> getSession ( ) -> getDriver ( ) -> getContent ( ) ) ) ) { throw new \ RuntimeException ( 'JSON response seems to be invalid' ) ; } return $ decoded ; } | Gets the last JSON response . |
3,464 | public function withIndex ( string $ index ) : self { $ metadata = clone $ this ; $ metadata -> index = $ index ; return $ metadata ; } | Gets a new instance with the given index . |
3,465 | public function withType ( string $ type ) : self { $ metadata = clone $ this ; $ metadata -> type = $ type ; return $ metadata ; } | Gets a new instance with the given type . |
3,466 | public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; if ( ! ( $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) || ! $ attributes [ 'receive' ] ) { return ; } if ( null === $ filters = $ request -> attributes -> get ( '_api_filters' )... | Calls the data provider and sets the data attribute . |
3,467 | protected function addWhere ( QueryBuilder $ queryBuilder , QueryNameGeneratorInterface $ queryNameGenerator , $ alias , $ field , $ operator , $ value ) { $ valueParameter = $ queryNameGenerator -> generateParameterName ( $ field ) ; switch ( $ operator ) { case self :: PARAMETER_BETWEEN : $ rangeValue = explode ( '..... | Adds the where clause according to the operator . |
3,468 | private function getContext ( Request $ request , Documentation $ documentation ) : array { $ context = [ 'title' => $ this -> title , 'description' => $ this -> description , 'formats' => $ this -> formats , 'showWebby' => $ this -> showWebby , 'swaggerUiEnabled' => $ this -> swaggerUiEnabled , 'reDocEnabled' => $ thi... | Gets the base Twig context . |
3,469 | public static function hasRootEntityWithForeignKeyIdentifier ( QueryBuilder $ queryBuilder , ManagerRegistry $ managerRegistry ) : bool { foreach ( $ queryBuilder -> getRootEntities ( ) as $ rootEntity ) { $ rootMetadata = $ managerRegistry -> getManagerForClass ( $ rootEntity ) -> getClassMetadata ( $ rootEntity ) ; i... | Determines whether the QueryBuilder has any root entity with foreign key identifier . |
3,470 | public static function hasRootEntityWithCompositeIdentifier ( QueryBuilder $ queryBuilder , ManagerRegistry $ managerRegistry ) : bool { foreach ( $ queryBuilder -> getRootEntities ( ) as $ rootEntity ) { $ rootMetadata = $ managerRegistry -> getManagerForClass ( $ rootEntity ) -> getClassMetadata ( $ rootEntity ) ; if... | Determines whether the QueryBuilder has any composite identifier . |
3,471 | public static function hasLeftJoin ( QueryBuilder $ queryBuilder ) : bool { foreach ( $ queryBuilder -> getDQLPart ( 'join' ) as $ joins ) { foreach ( $ joins as $ join ) { if ( Join :: LEFT_JOIN === $ join -> getJoinType ( ) ) { return true ; } } } return false ; } | Determines whether the QueryBuilder already has a left join . |
3,472 | public static function hasJoinedToManyAssociation ( QueryBuilder $ queryBuilder , ManagerRegistry $ managerRegistry ) : bool { if ( 0 === \ count ( $ queryBuilder -> getDQLPart ( 'join' ) ) ) { return false ; } $ joinAliases = array_diff ( $ queryBuilder -> getAllAliases ( ) , $ queryBuilder -> getRootAliases ( ) ) ; i... | Determines whether the QueryBuilder has a joined to - many association . |
3,473 | public static function guessErrorFormat ( Request $ request , array $ errorFormats ) : array { $ requestFormat = $ request -> getRequestFormat ( '' ) ; if ( '' !== $ requestFormat && isset ( $ errorFormats [ $ requestFormat ] ) ) { return [ 'key' => $ requestFormat , 'value' => $ errorFormats [ $ requestFormat ] ] ; } ... | Get the error format and its associated MIME type . |
3,474 | private function getNormalizationContext ( string $ resourceClass , string $ contextType , array $ options ) : array { if ( null !== $ this -> requestStack && null !== $ this -> serializerContextBuilder && null !== $ request = $ this -> requestStack -> getCurrentRequest ( ) ) { return $ this -> serializerContextBuilder... | Gets the serializer context . |
3,475 | public function onKernelView ( GetResponseForControllerResultEvent $ event ) : void { $ controllerResult = $ event -> getControllerResult ( ) ; $ request = $ event -> getRequest ( ) ; if ( $ controllerResult instanceof Response || ! ( ( $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) [ 'r... | Serializes the data to the requested format . |
3,476 | private function getQueryBuilderWithNewAliases ( QueryBuilder $ queryBuilder , QueryNameGeneratorInterface $ queryNameGenerator , string $ originAlias = 'o' , string $ replacement = 'o_2' ) : QueryBuilder { $ queryBuilderClone = clone $ queryBuilder ; $ joinParts = $ queryBuilder -> getDQLPart ( 'join' ) ; $ wherePart ... | Returns a clone of the given query builder where everything gets re - aliased . |
3,477 | private function getOperationRoute ( string $ resourceClass , string $ operationName , string $ operationType ) : Route { $ routeName = $ this -> getRouteName ( $ this -> resourceMetadataFactory -> create ( $ resourceClass ) , $ operationName , $ operationType ) ; if ( null !== $ routeName ) { return $ this -> getRoute... | Gets the route related to the given operation . |
3,478 | private function getRouteName ( ResourceMetadata $ resourceMetadata , string $ operationName , string $ operationType ) : ? string { if ( OperationType :: ITEM === $ operationType ) { return $ resourceMetadata -> getItemOperationAttribute ( $ operationName , 'route_name' ) ; } return $ resourceMetadata -> getCollection... | Gets the route name or null if not defined . |
3,479 | private function getRoute ( string $ routeName ) : Route { foreach ( $ this -> router -> getRouteCollection ( ) as $ name => $ route ) { if ( $ routeName === $ name ) { return $ route ; } } throw new RuntimeException ( sprintf ( 'The route "%s" does not exist.' , $ routeName ) ) ; } | Gets the route with the given name . |
3,480 | private function getOperations ( \ SimpleXMLElement $ resource , string $ operationType ) : ? array { $ graphql = 'operation' === $ operationType ; if ( ! $ graphql && $ legacyOperations = $ this -> getAttributes ( $ resource , $ operationType ) ) { @ trigger_error ( sprintf ( 'Configuring "%1$s" tags without using a p... | Returns the array containing configured operations . Returns NULL if there is no operation configuration . |
3,481 | private function getAttributes ( \ SimpleXMLElement $ resource , string $ elementName , bool $ topLevel = false ) : array { $ attributes = [ ] ; foreach ( $ resource -> { $ elementName } as $ attribute ) { $ value = isset ( $ attribute -> attribute [ 0 ] ) ? $ this -> getAttributes ( $ attribute , 'attribute' ) : XmlUt... | Recursively transforms an attribute structure into an associative array . |
3,482 | private function getProperties ( \ SimpleXMLElement $ resource ) : array { $ properties = [ ] ; foreach ( $ resource -> property as $ property ) { $ properties [ ( string ) $ property [ 'name' ] ] = [ 'description' => $ this -> phpize ( $ property , 'description' , 'string' ) , 'readable' => $ this -> phpize ( $ proper... | Gets metadata of a property . |
3,483 | private function phpize ( \ SimpleXMLElement $ array , string $ key , string $ type ) { if ( ! isset ( $ array [ $ key ] ) ) { return null ; } switch ( $ type ) { case 'string' : return ( string ) $ array [ $ key ] ; case 'integer' : return ( int ) $ array [ $ key ] ; case 'bool' : return ( bool ) XmlUtils :: phpize ( ... | Transforms an XML attribute s value in a PHP value . |
3,484 | public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; $ method = $ request -> getMethod ( ) ; if ( 'DELETE' === $ method || $ request -> isMethodSafe ( false ) || ! ( $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) || ! $ attributes ... | Deserializes the data sent in the requested format . |
3,485 | private function getFormat ( Request $ request ) : string { $ contentType = $ request -> headers -> get ( 'CONTENT_TYPE' ) ; if ( null === $ contentType ) { throw new NotAcceptableHttpException ( 'The "Content-Type" header must exist.' ) ; } $ format = $ this -> formatMatcher -> getFormat ( $ contentType ) ; if ( null ... | Extracts the format from the Content - Type header and check that it is supported . |
3,486 | private function getRealClassName ( string $ className ) : string { if ( ( false === $ positionCg = strrpos ( $ className , '\\__CG__\\' ) ) && ( false === $ positionPm = strrpos ( $ className , '\\__PM__\\' ) ) ) { return $ className ; } if ( false !== $ positionCg ) { return substr ( $ className , $ positionCg + 8 ) ... | Get the real class name of a class name that could be a proxy . |
3,487 | private function getItemData ( $ identifiers , array $ attributes , array $ context ) { return $ this -> itemDataProvider -> getItem ( $ attributes [ 'resource_class' ] , $ identifiers , $ attributes [ 'item_operation_name' ] , $ context ) ; } | Gets data for an item operation . |
3,488 | private function getSubresourceData ( $ identifiers , array $ attributes , array $ context ) { if ( null === $ this -> subresourceDataProvider ) { throw new RuntimeException ( 'Subresources not supported' ) ; } return $ this -> subresourceDataProvider -> getSubresource ( $ attributes [ 'resource_class' ] , $ identifier... | Gets data for a nested operation . |
3,489 | private function registerSwaggerConfiguration ( ContainerBuilder $ container , array $ config , XmlFileLoader $ loader ) : void { if ( ! $ config [ 'enable_swagger' ] ) { return ; } $ loader -> load ( 'swagger.xml' ) ; if ( $ config [ 'enable_swagger_ui' ] || $ config [ 'enable_re_doc' ] ) { $ loader -> load ( 'swagger... | Registers the Swagger ReDoc and Swagger UI configuration . |
3,490 | private function getFormats ( array $ configFormats ) : array { $ formats = [ ] ; foreach ( $ configFormats as $ format => $ value ) { foreach ( $ value [ 'mime_types' ] as $ mimeType ) { $ formats [ $ format ] [ ] = $ mimeType ; } } return $ formats ; } | Normalizes the format from config to the one accepted by Symfony HttpFoundation . |
3,491 | private function addJsonLdContext ( ContextBuilderInterface $ contextBuilder , string $ resourceClass , array & $ context , array $ data = [ ] ) : array { if ( isset ( $ context [ 'jsonld_has_context' ] ) ) { return $ data ; } $ context [ 'jsonld_has_context' ] = true ; if ( isset ( $ context [ 'jsonld_embed_context' ]... | Updates the given JSON - LD document to add its |
3,492 | private function addRequestFormats ( Request $ request , array $ formats ) : void { foreach ( $ formats as $ format => $ mimeTypes ) { $ request -> setFormat ( $ format , ( array ) $ mimeTypes ) ; } } | Adds the supported formats to the request . |
3,493 | private function getNotAcceptableHttpException ( string $ accept , array $ mimeTypes = null ) : NotAcceptableHttpException { if ( null === $ mimeTypes ) { $ mimeTypes = array_keys ( $ this -> mimeTypes ) ; } return new NotAcceptableHttpException ( sprintf ( 'Requested format "%s" is not supported. Supported MIME types ... | Retrieves an instance of NotAcceptableHttpException . |
3,494 | public function getProperty ( string $ methodName ) : ? string { $ pattern = implode ( '|' , array_merge ( self :: ACCESSOR_PREFIXES , self :: MUTATOR_PREFIXES ) ) ; if ( preg_match ( '/^(' . $ pattern . ')(.+)$/i' , $ methodName , $ matches ) ) { return $ matches [ 2 ] ; } return null ; } | Gets the property name associated with an accessor method . |
3,495 | public function getOffset ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : int { $ graphql = $ context [ 'graphql' ] ?? false ; $ limit = $ this -> getLimit ( $ resourceClass , $ operationName , $ context ) ; if ( $ graphql && null !== ( $ after = $ this -> getParameterFromCon... | Gets the current offset . |
3,496 | public function getLimit ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : int { $ graphql = $ context [ 'graphql' ] ?? false ; $ limit = $ this -> options [ 'items_per_page' ] ; $ clientLimit = $ this -> options [ 'client_items_per_page' ] ; if ( null !== $ resourceClass ) { $... | Gets the current limit . |
3,497 | public function getPagination ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : array { $ page = $ this -> getPage ( $ context ) ; $ limit = $ this -> getLimit ( $ resourceClass , $ operationName , $ context ) ; if ( 0 === $ limit && 1 < $ page ) { throw new InvalidArgumentExce... | Gets info about the pagination . |
3,498 | public function isEnabled ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : bool { return $ this -> getEnabled ( $ context , $ resourceClass , $ operationName ) ; } | Is the pagination enabled? |
3,499 | public function isPartialEnabled ( string $ resourceClass = null , string $ operationName = null , array $ context = [ ] ) : bool { return $ this -> getEnabled ( $ context , $ resourceClass , $ operationName , true ) ; } | Is the partial pagination enabled? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.