idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
35,500 | public function encode ( string $ event , $ data ) { $ packet = Packet :: MESSAGE . Packet :: EVENT ; $ shouldEncode = is_array ( $ data ) || is_object ( $ data ) ; $ data = $ shouldEncode ? json_encode ( $ data ) : $ data ; $ format = $ shouldEncode ? '["%s",%s]' : '["%s","%s"]' ; return $ packet . sprintf ( $ format ... | Encode output payload for websocket push . |
35,501 | public function decode ( $ frame ) { $ payload = Packet :: getPayload ( $ frame -> data ) ; return [ 'event' => $ payload [ 'event' ] ?? null , 'data' => $ payload [ 'data' ] ?? null , ] ; } | Decode message from websocket client . Define and return payload here . |
35,502 | public function logout ( ) { if ( is_null ( $ userId = $ this -> getUserId ( ) ) ) { return null ; } return $ this -> leave ( static :: USER_PREFIX . $ userId ) ; } | Logout with current sender s fd . |
35,503 | public function toUser ( $ users ) { $ users = is_object ( $ users ) ? func_get_args ( ) : $ users ; $ userIds = array_map ( function ( AuthenticatableContract $ user ) { $ this -> checkUser ( $ user ) ; return $ user -> getAuthIdentifier ( ) ; } , $ users ) ; return $ this -> toUserId ( $ userIds ) ; } | Set multiple recepients fds by users . |
35,504 | public function toUserId ( $ userIds ) { $ userIds = is_string ( $ userIds ) || is_integer ( $ userIds ) ? func_get_args ( ) : $ userIds ; foreach ( $ userIds as $ userId ) { $ fds = $ this -> room -> getClients ( static :: USER_PREFIX . $ userId ) ; $ this -> to ( $ fds ) ; } return $ this ; } | Set multiple recepients fds by userIds . |
35,505 | public function getUserId ( ) { if ( ! is_null ( $ this -> userId ) ) { return $ this -> userId ; } $ rooms = $ this -> room -> getRooms ( $ this -> getSender ( ) ) ; foreach ( $ rooms as $ room ) { if ( count ( $ explode = explode ( static :: USER_PREFIX , $ room ) ) === 2 ) { $ this -> userId = $ explode [ 1 ] ; } } ... | Get current auth user id by sender s fd . |
35,506 | protected function createIlluminateRequest ( $ get , $ post , $ cookie , $ files , $ server , $ content = null ) { IlluminateRequest :: enableHttpMethodParameterOverride ( ) ; if ( 'cli-server' === PHP_SAPI ) { if ( array_key_exists ( 'HTTP_CONTENT_LENGTH' , $ server ) ) { $ server [ 'CONTENT_LENGTH' ] = $ server [ 'HT... | Create Illuminate Request . |
35,507 | protected static function toIlluminateParameters ( SwooleRequest $ request ) { $ get = $ request -> get ?? [ ] ; $ post = $ request -> post ?? [ ] ; $ cookie = $ request -> cookie ?? [ ] ; $ files = $ request -> files ?? [ ] ; $ header = $ request -> header ?? [ ] ; $ server = $ request -> server ?? [ ] ; $ server = st... | Transforms request parameters . |
35,508 | public static function handleStatic ( $ swooleRequest , $ swooleResponse , string $ publicPath ) { $ uri = $ swooleRequest -> server [ 'request_uri' ] ?? '' ; $ extension = strtok ( pathinfo ( $ uri , PATHINFO_EXTENSION ) , '?' ) ; $ fileName = $ publicPath . $ uri ; if ( $ extension && in_array ( $ extension , static ... | Handle static request . |
35,509 | public function log ( Request $ request , Response $ response ) : void { $ host = $ request -> url ( ) ; $ method = $ request -> method ( ) ; $ agent = $ request -> userAgent ( ) ; $ date = $ this -> date ( $ response -> getDate ( ) ) ; $ status = $ response -> status ( ) ; $ style = $ this -> style ( $ status ) ; $ th... | Access log . |
35,510 | public function setRedis ( ? RedisClient $ redis = null ) { if ( ! $ redis ) { $ server = Arr :: get ( $ this -> config , 'server' , [ ] ) ; $ options = Arr :: get ( $ this -> config , 'options' , [ ] ) ; if ( Arr :: has ( $ options , 'prefix' ) ) { $ options = Arr :: except ( $ options , 'prefix' ) ; } $ redis = new R... | Set redis client . |
35,511 | public function addValue ( $ key , array $ values , string $ table ) { $ this -> checkTable ( $ table ) ; $ redisKey = $ this -> getKey ( $ key , $ table ) ; $ this -> redis -> pipeline ( function ( Pipeline $ pipe ) use ( $ redisKey , $ values ) { foreach ( $ values as $ value ) { $ pipe -> sadd ( $ redisKey , $ value... | Add value to redis . |
35,512 | public function removeValue ( $ key , array $ values , string $ table ) { $ this -> checkTable ( $ table ) ; $ redisKey = $ this -> getKey ( $ key , $ table ) ; $ this -> redis -> pipeline ( function ( Pipeline $ pipe ) use ( $ redisKey , $ values ) { foreach ( $ values as $ value ) { $ pipe -> srem ( $ redisKey , $ va... | Remove value from reddis . |
35,513 | protected function cleanRooms ( ) : void { if ( count ( $ keys = $ this -> redis -> keys ( "{$this->prefix}*" ) ) ) { $ this -> redis -> del ( $ keys ) ; } } | Clean all rooms . |
35,514 | public function to ( $ values ) : self { $ values = is_string ( $ values ) || is_integer ( $ values ) ? func_get_args ( ) : $ values ; foreach ( $ values as $ value ) { if ( ! in_array ( $ value , $ this -> to ) ) { $ this -> to [ ] = $ value ; } } return $ this ; } | Set multiple recipients fd or room names . |
35,515 | public function join ( $ rooms ) : self { $ rooms = is_string ( $ rooms ) || is_integer ( $ rooms ) ? func_get_args ( ) : $ rooms ; $ this -> room -> add ( $ this -> sender , $ rooms ) ; return $ this ; } | Join sender to multiple rooms . |
35,516 | public function leave ( $ rooms = [ ] ) : self { $ rooms = is_string ( $ rooms ) || is_integer ( $ rooms ) ? func_get_args ( ) : $ rooms ; $ this -> room -> delete ( $ this -> sender , $ rooms ) ; return $ this ; } | Make sender leave multiple rooms . |
35,517 | public function on ( string $ event , $ callback ) { if ( ! is_string ( $ callback ) && ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( 'Invalid websocket callback. Must be a string or callable.' ) ; } $ this -> callbacks [ $ event ] = $ callback ; return $ this ; } | Register an event name with a closure binding . |
35,518 | public function close ( int $ fd = null ) { return App :: make ( Server :: class ) -> close ( $ fd ? : $ this -> sender ) ; } | Close current connection . |
35,519 | protected function getFds ( ) { $ fds = array_filter ( $ this -> to , function ( $ value ) { return is_integer ( $ value ) ; } ) ; $ rooms = array_diff ( $ this -> to , $ fds ) ; foreach ( $ rooms as $ room ) { $ clients = $ this -> room -> getClients ( $ room ) ; if ( empty ( $ clients ) && is_numeric ( $ room ) ) { $... | Get all fds we re going to push data to . |
35,520 | public function reset ( $ force = false ) { $ this -> isBroadcast = false ; $ this -> to = [ ] ; if ( $ force ) { $ this -> sender = null ; $ this -> userId = null ; } return $ this ; } | Reset some data status . |
35,521 | public function middleware ( $ middleware = null ) { if ( is_null ( $ middleware ) ) { return $ this -> middleware ; } if ( is_string ( $ middleware ) ) { $ middleware = func_get_args ( ) ; } $ this -> middleware = array_unique ( array_merge ( $ this -> middleware , $ middleware ) ) ; return $ this ; } | Get or set middleware . |
35,522 | public function setContainer ( Container $ container ) { $ pipeline = $ this -> pipeline ; $ closure = function ( ) use ( $ container ) { $ this -> container = $ container ; } ; $ resetPipeline = $ closure -> bindTo ( $ pipeline , $ pipeline ) ; $ resetPipeline ( ) ; return $ this ; } | Set container to pipeline . |
35,523 | protected function setRequestThroughMiddleware ( $ request ) { return $ this -> pipeline -> send ( $ request ) -> through ( $ this -> middleware ) -> then ( function ( $ request ) { return $ request ; } ) ; } | Set the given request through the middleware . |
35,524 | protected function isWebsocketPushPacket ( $ packet ) { if ( ! is_array ( $ packet ) ) { return false ; } return $ this -> isWebsocket && array_key_exists ( 'action' , $ packet ) && $ packet [ 'action' ] === Websocket :: PUSH_ACTION ; } | Indicates if a packet is websocket push action . |
35,525 | public function pushMessage ( $ server , array $ data ) { $ pusher = Pusher :: make ( $ data , $ server ) ; $ pusher -> push ( $ this -> payloadParser -> encode ( $ pusher -> getEvent ( ) , $ pusher -> getMessage ( ) ) ) ; } | Push websocket message to clients . |
35,526 | protected function prepareWebsocket ( ) { $ config = $ this -> container -> make ( 'config' ) ; $ isWebsocket = $ config -> get ( 'swoole_http.websocket.enabled' ) ; $ parser = $ config -> get ( 'swoole_websocket.parser' ) ; if ( $ isWebsocket ) { $ this -> events = array_merge ( $ this -> events ?? [ ] , $ this -> wsE... | Prepare settings if websocket is enabled . |
35,527 | protected function loadWebsocketRoutes ( ) { $ routePath = $ this -> container -> make ( 'config' ) -> get ( 'swoole_websocket.route_file' ) ; if ( ! file_exists ( $ routePath ) ) { $ routePath = __DIR__ . '/../../routes/websocket.php' ; } return require $ routePath ; } | Load websocket routes file . |
35,528 | public function isWebsocketPushPayload ( $ payload ) : bool { if ( ! is_array ( $ payload ) ) { return false ; } return $ this -> isServerWebsocket && ( $ payload [ 'action' ] ?? null ) === Websocket :: PUSH_ACTION && array_key_exists ( 'data' , $ payload ) ; } | Indicates if the payload is websocket push . |
35,529 | public static function getSocketType ( string $ packet ) { $ type = $ packet [ 0 ] ?? null ; if ( ! array_key_exists ( $ type , static :: $ socketTypes ) ) { return null ; } return ( int ) $ type ; } | Get socket packet type of a raw payload . |
35,530 | public static function getPayload ( string $ packet ) { $ packet = trim ( $ packet ) ; $ start = strpos ( $ packet , '[' ) ; if ( $ start === false || substr ( $ packet , - 1 ) !== ']' ) { return null ; } $ data = substr ( $ packet , $ start , strlen ( $ packet ) - $ start ) ; $ data = json_decode ( $ data , true ) ; i... | Get data packet from a raw payload . |
35,531 | public static function isSocketType ( $ packet , string $ typeName ) { $ type = array_search ( strtoupper ( $ typeName ) , static :: $ socketTypes ) ; if ( $ type === false ) { return false ; } return static :: getSocketType ( $ packet ) === $ type ; } | Return if a socket packet belongs to specific type . |
35,532 | public function make ( ? callable $ callback = null ) { $ mcb = function ( $ type , $ buffer ) use ( $ callback ) { if ( ! $ this -> locked && AppProcess :: OUT === $ type && $ event = FSEventParser :: toEvent ( $ buffer ) ) { $ this -> locked = true ; ( $ callback ) ? $ callback ( $ event ) : null ; $ this -> locked =... | Make swoole process . |
35,533 | protected function bootstrap ( ) { if ( $ this -> framework === 'laravel' ) { $ bootstrappers = $ this -> getBootstrappers ( ) ; $ this -> app -> bootstrapWith ( $ bootstrappers ) ; } else { if ( method_exists ( $ this -> app , 'boot' ) ) { $ this -> app -> boot ( ) ; } $ this -> app -> withFacades ( ) ; } $ this -> pr... | Bootstrap framework . |
35,534 | protected function setFramework ( $ framework ) { $ framework = strtolower ( $ framework ) ; if ( ! in_array ( $ framework , [ 'laravel' , 'lumen' ] ) ) { throw new FrameworkNotSupportException ( $ framework ) ; } $ this -> framework = $ framework ; } | Set framework . |
35,535 | protected function preResolveInstances ( ) { $ resolves = $ this -> container -> make ( 'config' ) -> get ( 'swoole_http.pre_resolved' , [ ] ) ; foreach ( $ resolves as $ abstract ) { if ( $ this -> getApplication ( ) -> offsetExists ( $ abstract ) ) { $ this -> getApplication ( ) -> make ( $ abstract ) ; } } } | Reslove some instances before request . |
35,536 | protected function getBootstrappers ( ) { $ kernel = $ this -> getApplication ( ) -> make ( Kernel :: class ) ; $ reflection = new \ ReflectionObject ( $ kernel ) ; $ bootstrappersMethod = $ reflection -> getMethod ( 'bootstrappers' ) ; $ bootstrappersMethod -> setAccessible ( true ) ; $ bootstrappers = $ bootstrappers... | Get bootstrappers . |
35,537 | protected function rebindProviderContainer ( $ app , $ provider ) { $ closure = function ( ) use ( $ app ) { $ this -> app = $ app ; } ; $ resetProvider = $ closure -> bindTo ( $ provider , $ provider ) ; $ resetProvider ( ) ; } | Rebind service provider s container . |
35,538 | public function terminate ( Request $ request , Response $ response ) { $ this -> output -> log ( $ request , $ response ) ; } | Handle the outgoing request and response . |
35,539 | protected function start ( ) { if ( $ this -> isRunning ( $ this -> getCurrentPid ( ) ) ) { $ this -> error ( 'Failed! swoole_http_server process is already running.' ) ; return ; } $ host = Arr :: get ( $ this -> config , 'server.host' ) ; $ port = Arr :: get ( $ this -> config , 'server.port' ) ; $ hotReloadEnabled =... | Run swoole_http_server . |
35,540 | protected function stop ( ) { $ pid = $ this -> getCurrentPid ( ) ; if ( ! $ this -> isRunning ( $ pid ) ) { $ this -> error ( "Failed! There is no swoole_http_server process running." ) ; return ; } $ this -> info ( 'Stopping swoole http server...' ) ; $ isRunning = $ this -> killProcess ( $ pid , SIGTERM , 15 ) ; if ... | Stop swoole_http_server . |
35,541 | protected function restart ( ) { $ pid = $ this -> getCurrentPid ( ) ; if ( $ this -> isRunning ( $ pid ) ) { $ this -> stop ( ) ; } $ this -> start ( ) ; } | Restart swoole http server . |
35,542 | protected function showInfos ( ) { $ pid = $ this -> getCurrentPid ( ) ; $ isRunning = $ this -> isRunning ( $ pid ) ; $ host = Arr :: get ( $ this -> config , 'server.host' ) ; $ port = Arr :: get ( $ this -> config , 'server.port' ) ; $ reactorNum = Arr :: get ( $ this -> config , 'server.options.reactor_num' ) ; $ w... | Display PHP and Swoole miscs infos . |
35,543 | protected function initAction ( ) { $ this -> action = $ this -> argument ( 'action' ) ; if ( ! in_array ( $ this -> action , [ 'start' , 'stop' , 'restart' , 'reload' , 'infos' ] , true ) ) { $ this -> error ( "Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'." ) ; return ; ... | Initialize command action . |
35,544 | protected function isRunning ( $ pid ) { if ( ! $ pid ) { return false ; } try { return Process :: kill ( $ pid , 0 ) ; } catch ( Throwable $ e ) { return false ; } } | If Swoole process is running . |
35,545 | protected function killProcess ( $ pid , $ sig , $ wait = 0 ) { Process :: kill ( $ pid , $ sig ) ; if ( $ wait ) { $ start = time ( ) ; do { if ( ! $ this -> isRunning ( $ pid ) ) { break ; } usleep ( 100000 ) ; } while ( time ( ) < $ start + $ wait ) ; } return $ this -> isRunning ( $ pid ) ; } | Kill process . |
35,546 | protected function getCurrentPid ( ) { if ( $ this -> currentPid ) { return $ this -> currentPid ; } $ path = $ this -> getPidPath ( ) ; return $ this -> currentPid = file_exists ( $ path ) ? ( int ) file_get_contents ( $ path ) ?? $ this -> removePidFile ( ) : null ; } | Get pid . |
35,547 | protected function checkEnvironment ( ) { if ( OS :: is ( OS :: WIN ) ) { $ this -> error ( 'Swoole extension doesn\'t support Windows OS.' ) ; exit ( 1 ) ; } if ( ! extension_loaded ( 'swoole' ) ) { $ this -> error ( 'Can\'t detect Swoole extension installed.' ) ; exit ( 1 ) ; } if ( ! version_compare ( swoole_version... | Check running enironment . |
35,548 | protected function registerAccessLog ( ) { $ this -> laravel -> singleton ( OutputStyle :: class , function ( ) { return new OutputStyle ( $ this -> input , $ this -> output ) ; } ) ; $ this -> laravel -> singleton ( AccessOutput :: class , function ( ) { return new AccessOutput ( new ConsoleOutput ) ; } ) ; $ this -> ... | Register access log services . |
35,549 | protected function sendContent ( ) { $ illuminateResponse = $ this -> getIlluminateResponse ( ) ; if ( $ illuminateResponse instanceof StreamedResponse && property_exists ( $ illuminateResponse , 'output' ) ) { $ this -> swooleResponse -> end ( $ illuminateResponse -> output ) ; } elseif ( $ illuminateResponse instance... | Send HTTP content . |
35,550 | protected function sendInChunk ( $ content ) { if ( strlen ( $ content ) <= static :: CHUNK_SIZE ) { $ this -> swooleResponse -> end ( $ content ) ; return ; } foreach ( str_split ( $ content , static :: CHUNK_SIZE ) as $ chunk ) { $ this -> swooleResponse -> write ( $ chunk ) ; } $ this -> swooleResponse -> end ( ) ; ... | Send content in chunk |
35,551 | public function format ( array $ record ) : string { if ( ! empty ( $ this -> hostname ) ) { $ record [ "hostname" ] = $ this -> hostname ; } if ( ! empty ( $ this -> appname ) ) { $ record [ "appname" ] = $ this -> appname ; } $ record [ "@marker" ] = static :: MARKERS ; return parent :: format ( $ record ) ; } | Appends the hostname and appname parameter for indexing by Logmatic . |
35,552 | protected function formatBatchNewlines ( array $ records ) : string { $ instance = $ this ; $ oldNewline = $ this -> appendNewline ; $ this -> appendNewline = false ; array_walk ( $ records , function ( & $ value , $ key ) use ( $ instance ) { $ value = $ instance -> format ( $ value ) ; } ) ; $ this -> appendNewline =... | Use new lines to separate records instead of a JSON - encoded array . |
35,553 | public function setJsonPrettyPrint ( bool $ enable ) : self { if ( $ enable ) { $ this -> jsonEncodeOptions |= JSON_PRETTY_PRINT ; } else { $ this -> jsonEncodeOptions ^= JSON_PRETTY_PRINT ; } return $ this ; } | Enables json_encode pretty print . |
35,554 | protected function toJson ( $ data , bool $ ignoreErrors = false ) { if ( $ ignoreErrors ) { return @ $ this -> jsonEncode ( $ data ) ; } $ json = $ this -> jsonEncode ( $ data ) ; if ( $ json === false ) { $ json = $ this -> handleJsonError ( json_last_error ( ) , $ data ) ; } return $ json ; } | Return the JSON representation of a value |
35,555 | private function handleJsonError ( int $ code , $ data ) : string { if ( $ code !== JSON_ERROR_UTF8 ) { $ this -> throwEncodeError ( $ code , $ data ) ; } if ( is_string ( $ data ) ) { $ this -> detectAndCleanUtf8 ( $ data ) ; } elseif ( is_array ( $ data ) ) { array_walk_recursive ( $ data , [ $ this , 'detectAndClean... | Handle a json_encode failure . |
35,556 | private function throwEncodeError ( int $ code , $ data ) { switch ( $ code ) { case JSON_ERROR_DEPTH : $ msg = 'Maximum stack depth exceeded' ; break ; case JSON_ERROR_STATE_MISMATCH : $ msg = 'Underflow or the modes mismatch' ; break ; case JSON_ERROR_CTRL_CHAR : $ msg = 'Unexpected control character found' ; break ;... | Throws an exception according to a given code with a customized message |
35,557 | protected function connectUdp ( ) : void { if ( ! extension_loaded ( 'sockets' ) ) { throw new MissingExtensionException ( 'The sockets extension is required to use udp URLs with the CubeHandler' ) ; } $ this -> udpConnection = socket_create ( AF_INET , SOCK_DGRAM , 0 ) ; if ( ! $ this -> udpConnection ) { throw new \ ... | Establish a connection to an UDP socket |
35,558 | protected function connectHttp ( ) : void { if ( ! extension_loaded ( 'curl' ) ) { throw new MissingExtensionException ( 'The curl extension is required to use http URLs with the CubeHandler' ) ; } $ this -> httpConnection = curl_init ( 'http://' . $ this -> host . ':' . $ this -> port . '/1.0/event/put' ) ; if ( ! $ t... | Establish a connection to an http server |
35,559 | public function setHandlers ( array $ handlers ) : self { $ this -> handlers = [ ] ; foreach ( array_reverse ( $ handlers ) as $ handler ) { $ this -> pushHandler ( $ handler ) ; } return $ this ; } | Set handlers replacing all existing ones . |
35,560 | public function reset ( ) : void { foreach ( $ this -> handlers as $ handler ) { if ( $ handler instanceof ResettableInterface ) { $ handler -> reset ( ) ; } } foreach ( $ this -> processors as $ processor ) { if ( $ processor instanceof ResettableInterface ) { $ processor -> reset ( ) ; } } } | Ends a log cycle and resets all handlers and processors to their initial state . |
35,561 | protected function handleException ( Throwable $ e , array $ record ) { if ( ! $ this -> exceptionHandler ) { throw $ e ; } call_user_func ( $ this -> exceptionHandler , $ e , $ record ) ; } | Delegates exception management to the custom exception handler or throws the exception if no custom handler is set . |
35,562 | protected function write ( array $ record ) : void { if ( ! isset ( $ record [ 'formatted' ] ) || 'string' !== gettype ( $ record [ 'formatted' ] ) ) { throw new \ InvalidArgumentException ( 'SqsHandler accepts only formatted records as a string' ) ; } $ messageBody = $ record [ 'formatted' ] ; if ( strlen ( $ messageB... | Writes the record down to the log of the implementing handler . |
35,563 | protected function finalizeWrite ( ) : void { $ res = $ this -> getResource ( ) ; if ( is_resource ( $ res ) ) { @ fread ( $ res , 2048 ) ; } $ this -> closeSocket ( ) ; } | Finalizes the request by reading some bytes and then closing the socket |
35,564 | private function combineRecords ( array $ records ) : array { $ batchRecord = null ; $ batchRecords = [ ] ; $ messages = [ ] ; $ formattedMessages = [ ] ; $ level = 0 ; $ levelName = null ; $ datetime = null ; foreach ( $ records as $ record ) { $ record = $ this -> processRecord ( $ record ) ; if ( $ record [ 'level' ... | Combines multiple records into one . Error level of the combined record will be the highest level from the given records . Datetime will be taken from the first record . |
35,565 | private function generateAttachmentField ( string $ title , $ value ) : array { $ value = is_array ( $ value ) ? sprintf ( '```%s```' , $ this -> stringify ( $ value ) ) : $ value ; return array ( 'title' => ucfirst ( $ title ) , 'value' => $ value , 'short' => false , ) ; } | Generates attachment field |
35,566 | private function generateAttachmentFields ( array $ data ) : array { $ fields = array ( ) ; foreach ( $ this -> normalizerFormatter -> format ( $ data ) as $ key => $ value ) { $ fields [ ] = $ this -> generateAttachmentField ( $ key , $ value ) ; } return $ fields ; } | Generates a collection of attachment fields from array |
35,567 | public function addParameter ( $ parameters ) : self { $ this -> parameters = array_merge ( $ this -> parameters , ( array ) $ parameters ) ; return $ this ; } | Add parameters to the message |
35,568 | public static function addLogger ( Logger $ logger , ? string $ name = null , bool $ overwrite = false ) { $ name = $ name ? : $ logger -> getName ( ) ; if ( isset ( self :: $ loggers [ $ name ] ) && ! $ overwrite ) { throw new InvalidArgumentException ( 'Logger with the given name already exists' ) ; } self :: $ logge... | Adds new logging channel to the registry |
35,569 | public function activate ( ) : void { if ( $ this -> stopBuffering ) { $ this -> buffering = false ; } if ( ! $ this -> handler instanceof HandlerInterface ) { $ record = end ( $ this -> buffer ) ? : null ; $ this -> handler = call_user_func ( $ this -> handler , $ record , $ this ) ; if ( ! $ this -> handler instanceo... | Manually activate this logger regardless of the activation strategy |
35,570 | private function flushBuffer ( ) : void { if ( null !== $ this -> passthruLevel ) { $ level = $ this -> passthruLevel ; $ this -> buffer = array_filter ( $ this -> buffer , function ( $ record ) use ( $ level ) { return $ record [ 'level' ] >= $ level ; } ) ; if ( count ( $ this -> buffer ) > 0 ) { $ this -> handler ->... | Resets the state of the handler . Stops forwarding records to the wrapped handler . |
35,571 | private function legacyGetMongoDbDateTime ( \ DateTimeInterface $ value ) : UTCDateTime { $ milliseconds = floor ( $ value -> format ( 'U.u' ) * 1000 ) ; $ milliseconds = ( PHP_INT_SIZE == 8 ) ? ( int ) $ milliseconds : ( string ) $ milliseconds ; return new UTCDateTime ( $ milliseconds ) ; } | This is needed to support MongoDB Driver v1 . 19 and below |
35,572 | private function ensureProcessIsStarted ( ) : void { if ( is_resource ( $ this -> process ) === false ) { $ this -> startProcess ( ) ; $ this -> handleStartupErrors ( ) ; } } | Makes sure that the process is actually started and if not starts it assigns the stream pipes and handles startup errors if any . |
35,573 | private function startProcess ( ) : void { $ this -> process = proc_open ( $ this -> command , static :: DESCRIPTOR_SPEC , $ this -> pipes , $ this -> cwd ) ; foreach ( $ this -> pipes as $ pipe ) { stream_set_blocking ( $ pipe , false ) ; } } | Starts the actual process and sets all streams to non - blocking . |
35,574 | private function handleStartupErrors ( ) : void { $ selected = $ this -> selectErrorStream ( ) ; if ( false === $ selected ) { throw new \ UnexpectedValueException ( 'Something went wrong while selecting a stream.' ) ; } $ errors = $ this -> readProcessErrors ( ) ; if ( is_resource ( $ this -> process ) === false || em... | Selects the STDERR stream handles upcoming startup errors and throws an exception if any . |
35,575 | protected function write ( array $ record ) : void { if ( ! $ this -> isWebRequest ( ) ) { return ; } self :: $ json [ 'rows' ] [ ] = $ record [ 'formatted' ] ; $ this -> send ( ) ; } | Creates & sends header for a record |
35,576 | protected function send ( ) : void { if ( self :: $ overflowed || ! self :: $ sendHeaders ) { return ; } if ( ! self :: $ initialized ) { self :: $ initialized = true ; self :: $ sendHeaders = $ this -> headersAccepted ( ) ; if ( ! self :: $ sendHeaders ) { return ; } self :: $ json [ 'request_uri' ] = $ _SERVER [ 'REQ... | Sends the log header |
35,577 | protected function getInitHeaders ( ) : array { return array_merge ( $ this -> createHeader ( [ 'Protocol' , 1 ] , static :: PROTOCOL_URI ) , $ this -> createHeader ( [ 1 , 'Structure' , 1 ] , static :: STRUCTURE_URI ) , $ this -> createHeader ( [ 1 , 'Plugin' , 1 ] , static :: PLUGIN_URI ) ) ; } | Wildfire initialization headers to enable message parsing |
35,578 | public function setConnectionTimeout ( float $ seconds ) : self { $ this -> validateTimeout ( $ seconds ) ; $ this -> connectionTimeout = $ seconds ; return $ this ; } | Set connection timeout . Only has effect before we connect . |
35,579 | public function setTimeout ( float $ seconds ) : self { $ this -> validateTimeout ( $ seconds ) ; $ this -> timeout = $ seconds ; return $ this ; } | Set write timeout . Only has effect before we connect . |
35,580 | public function setWritingTimeout ( float $ seconds ) : self { $ this -> validateTimeout ( $ seconds ) ; $ this -> writingTimeout = $ seconds ; return $ this ; } | Set writing timeout . Only has effect during connection in the writing cycle . |
35,581 | public function index ( Metric $ metric , MetricPoint $ metricPoint ) { $ points = $ metric -> points ( ) -> paginate ( Binput :: get ( 'per_page' , 20 ) ) ; return $ this -> paginator ( $ points , Request :: instance ( ) ) ; } | Get a single metric point . |
35,582 | public function store ( Metric $ metric ) { try { $ metricPoint = execute ( new CreateMetricPointCommand ( $ metric , Binput :: get ( 'value' ) , Binput :: get ( 'timestamp' ) ) ) ; } catch ( QueryException $ e ) { throw new BadRequestHttpException ( ) ; } return $ this -> item ( $ metricPoint ) ; } | Create a new metric point . |
35,583 | public function update ( Metric $ metric , MetricPoint $ metricPoint ) { $ metricPoint = execute ( new UpdateMetricPointCommand ( $ metricPoint , $ metric , Binput :: get ( 'value' ) , Binput :: get ( 'timestamp' ) ) ) ; return $ this -> item ( $ metricPoint ) ; } | Updates a metric point . |
35,584 | public function destroy ( Metric $ metric , MetricPoint $ metricPoint ) { execute ( new RemoveMetricPointCommand ( $ metricPoint ) ) ; return $ this -> noContent ( ) ; } | Destroys a metric point . |
35,585 | public function handle ( $ command , Closure $ next ) { return DB :: transaction ( function ( ) use ( $ command , $ next ) { return $ next ( $ command ) ; } ) ; } | Handle the current command in the pipeline . |
35,586 | public function handle ( GenerateApiTokenCommand $ command ) { $ user = $ command -> user ; $ user -> update ( [ 'api_key' => User :: generateApiKey ( ) ] ) ; event ( new UserRegeneratedApiTokenEvent ( $ user ) ) ; } | Handle the generate api key command . |
35,587 | public function index ( ) { $ schedule = Schedule :: query ( ) ; if ( $ sortBy = Binput :: get ( 'sort' ) ) { $ direction = Binput :: has ( 'order' ) && Binput :: get ( 'order' ) == 'desc' ; $ schedule -> sort ( $ sortBy , $ direction ) ; } $ schedule = $ schedule -> paginate ( Binput :: get ( 'per_page' , 20 ) ) ; ret... | Return all schedules . |
35,588 | public function store ( ) { try { $ schedule = execute ( new CreateScheduleCommand ( Binput :: get ( 'name' ) , Binput :: get ( 'message' , null , false , false ) , Binput :: get ( 'status' ) , Binput :: get ( 'scheduled_at' ) , Binput :: get ( 'completed_at' ) , Binput :: get ( 'components' , [ ] ) ) ) ; } catch ( Que... | Create a new schedule . |
35,589 | public function update ( Schedule $ schedule ) { try { $ schedule = execute ( new UpdateScheduleCommand ( $ schedule , Binput :: get ( 'name' ) , Binput :: get ( 'message' ) , Binput :: get ( 'status' ) , Binput :: get ( 'scheduled_at' ) , Binput :: get ( 'completed_at' ) , Binput :: get ( 'components' , [ ] ) ) ) ; } ... | Update a schedule . |
35,590 | public function destroy ( Schedule $ schedule ) { try { execute ( new DeleteScheduleCommand ( $ schedule ) ) ; } catch ( QueryException $ e ) { throw new BadRequestHttpException ( ) ; } return $ this -> noContent ( ) ; } | Delete a schedule . |
35,591 | public function handle ( UpdateMetricPointCommand $ command ) { $ point = $ command -> point ; $ metric = $ command -> metric ; $ createdAt = $ command -> created_at ; $ data = [ 'metric_id' => $ metric -> id , 'value' => ( float ) $ command -> value , ] ; if ( $ createdAt ) { $ data [ 'created_at' ] = $ this -> dates ... | Handle the update metric point command . |
35,592 | public function handle ( InviteUserCommand $ command ) { foreach ( $ command -> emails as $ email ) { $ invite = Invite :: create ( [ 'email' => $ email , ] ) ; $ invite -> notify ( new InviteUserNotification ( ) ) ; event ( new UserWasInvitedEvent ( $ invite ) ) ; } } | Handle the invite team member command . |
35,593 | public function fireInstallingCommand ( Command $ command ) { $ this -> handleMainCommand ( $ command ) ; event ( new SystemWasInstalledEvent ( ) ) ; $ command -> info ( 'System was installed!' ) ; } | Fire the installing command . |
35,594 | public function fireUpdatingCommand ( Command $ command ) { $ this -> handleMainCommand ( $ command ) ; event ( new SystemWasUpdatedEvent ( ) ) ; $ command -> info ( 'System was updated!' ) ; } | Fire the updating command . |
35,595 | public function fireResettingCommand ( Command $ command ) { $ this -> handleMainCommand ( $ command ) ; event ( new SystemWasResetEvent ( ) ) ; $ command -> info ( 'System was reset!' ) ; } | Fire the resetting command . |
35,596 | protected function handleMainCommand ( Command $ command ) { $ command -> line ( 'Clearing settings cache...' ) ; $ this -> cache -> clear ( ) ; $ command -> line ( 'Settings cache cleared!' ) ; } | Handle the main bulk of the command clear the settings . |
35,597 | public function handle ( UpdateComponentCommand $ command ) { $ component = $ command -> component ; $ originalStatus = $ component -> status ; if ( $ command -> status && ( int ) $ originalStatus !== ( int ) $ command -> status ) { event ( new ComponentStatusWasChangedEvent ( $ this -> auth -> user ( ) , $ component ,... | Handle the update component command . |
35,598 | public function getIsResolvedAttribute ( ) { if ( $ updates = $ this -> updates -> first ( ) ) { return ( int ) $ updates -> status === self :: FIXED ; } return ( int ) $ this -> status === self :: FIXED ; } | Is the incident resolved? |
35,599 | public function handle ( UpdateIncidentCommand $ command ) { if ( $ template = IncidentTemplate :: where ( 'slug' , '=' , $ command -> template ) -> first ( ) ) { $ command -> message = $ this -> parseTemplate ( $ template , $ command ) ; } $ incident = $ command -> incident ; $ incident -> fill ( $ this -> filter ( $ ... | Handle the update incident command . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.