idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
55,900
public function setSchedule ( $ minute , $ hour , $ dayOfMonth , $ month , $ dayOfWeek , $ week = self :: NONE ) { $ month = $ this -> parseTimeParameter ( $ month ) ; $ week = $ this -> parseTimeParameter ( $ week ) ; $ dayOfMonth = $ this -> parseTimeParameter ( $ dayOfMonth ) ; $ dayOfWeek = $ this -> parseTimeParam...
Manually set a command s execution schedule . Parameter order follows standard cron syntax
55,901
public function quarterly ( ) { $ months = [ Month :: JANUARY , Month :: APRIL , Month :: JULY , Month :: OCTOBER ] ; $ this -> setScheduleMonth ( $ this -> parseTimeParameter ( $ months ) ) ; $ this -> setScheduleWeek ( self :: NONE ) ; $ this -> setScheduleDayOfMonth ( 1 ) ; $ this -> setScheduleDayOfWeek ( self :: A...
Run once a quarter at the beginning of the quarter
55,902
public function monthly ( ) { $ this -> setScheduleMonth ( self :: ANY ) ; $ this -> setScheduleWeek ( self :: NONE ) ; $ this -> setScheduleDayOfMonth ( 1 ) ; $ this -> setScheduleDayOfWeek ( self :: ANY ) ; $ this -> setScheduleHour ( 0 ) ; $ this -> setScheduleMinute ( 0 ) ; return $ this ; }
Run once a month at midnight in the morning of the first day of the month
55,903
public function everyOddWeek ( ) { $ this -> setScheduleMonth ( self :: ANY ) ; $ this -> setScheduleWeek ( 'odd' ) ; $ this -> setScheduleDayOfMonth ( self :: ANY ) ; $ this -> setScheduleDayOfWeek ( self :: ANY ) ; $ this -> setScheduleHour ( 0 ) ; $ this -> setScheduleMinute ( 0 ) ; return $ this ; }
Run once every odd week at midnight on Sunday morning
55,904
public function weekly ( ) { $ this -> setScheduleMonth ( self :: ANY ) ; $ this -> setScheduleWeek ( self :: ANY ) ; $ this -> setScheduleDayOfMonth ( self :: ANY ) ; $ this -> setScheduleDayOfWeek ( Day :: SUNDAY ) ; $ this -> setScheduleHour ( 0 ) ; $ this -> setScheduleMinute ( 0 ) ; return $ this ; }
Run once a week at midnight on Sunday morning
55,905
public function weekOfYear ( $ week ) { $ this -> setScheduleMonth ( self :: NONE ) ; $ this -> setScheduleWeek ( $ this -> parseTimeParameter ( $ week ) ) ; $ this -> setScheduleDayOfMonth ( self :: ANY ) ; $ this -> setScheduleDayOfWeek ( Day :: SUNDAY ) ; $ this -> setScheduleHour ( 0 ) ; $ this -> setScheduleMinute...
Run on the given week of each month
55,906
public function daily ( ) { $ this -> setScheduleMinute ( 0 ) ; $ this -> setScheduleHour ( 0 ) ; $ this -> setScheduleDayOfMonth ( self :: ANY ) ; $ this -> setScheduleMonth ( self :: ANY ) ; $ this -> setScheduleDayOfWeek ( self :: ANY ) ; return $ this ; }
Run once a day at midnight
55,907
public function everyMinutes ( $ minutes ) { $ minutesSchedule = self :: ANY ; if ( $ minutes != 1 ) { $ minutesSchedule .= '/' . $ minutes ; } $ this -> setScheduleMinute ( $ minutesSchedule ) ; return $ this ; }
Run a command every X minutes
55,908
protected function extendStub ( $ stub ) { $ files = App :: make ( 'Illuminate\Filesystem\Filesystem' ) ; $ content = $ files -> get ( __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'command.stub' ) ; $ replacements = [ 'use Illuminate\Console\Command' => "use Indatus\\Dispatcher\\Scheduling\\Scheduled...
Make sure we re implementing our own class
55,909
public function run ( ScheduledCommandInterface $ scheduledCommand , array $ arguments = [ ] , array $ options = [ ] , Debugger $ debugger = null ) { $ runCommand = $ this -> commandService -> getRunCommand ( $ scheduledCommand , $ arguments , $ options ) ; if ( ! is_null ( $ debugger ) ) { $ debugger -> commandRun ( $...
Run a scheduled command
55,910
public function isDue ( Schedulable $ scheduler ) { $ interpreter = App :: make ( 'Indatus\Dispatcher\Drivers\DateTime\ScheduleInterpreter' , [ $ scheduler ] ) ; $ logger = App :: make ( 'Illuminate\Contracts\Logging\Log' ) ; try { return $ interpreter -> isDue ( ) ; } catch ( Exception $ e ) { $ logger -> error ( $ e ...
Determine if a schedule is due to be run .
55,911
public function isDue ( ) { $ cron = App :: make ( 'Cron\CronExpression' , [ $ this -> scheduler -> getCronSchedule ( ) ] ) ; if ( $ this -> scheduler -> getScheduleWeek ( ) !== Scheduler :: NONE ) { return $ this -> thisWeek ( ) && $ cron -> isDue ( ) ; } return $ cron -> isDue ( ) ; }
Determine if the current schedule is due to be run
55,912
public function thisWeek ( ) { $ scheduleWeek = $ this -> scheduler -> getScheduleWeek ( ) ; $ currentWeek = $ this -> now -> format ( 'W' ) ; $ scheduleMonth = $ this -> scheduler -> getScheduleMonth ( ) ; if ( ! is_null ( $ scheduleMonth ) && $ scheduleMonth !== Scheduler :: NONE ) { return $ this -> isCurrent ( $ sc...
Determine if the provided expression refers to this week
55,913
protected function isCurrent ( $ expression , $ current ) { if ( $ expression == Scheduler :: ANY ) { return true ; } if ( is_array ( $ expression ) ) { return in_array ( $ current , $ expression ) ; } if ( ( string ) $ expression === ( string ) $ current ) { return true ; } return false ; }
This method checks syntax for all scheduling components .
55,914
public function args ( array $ arguments ) { if ( count ( $ this -> options ) == 0 ) { $ scheduler = App :: make ( get_called_class ( ) ) ; $ scheduler -> setArguments ( $ arguments ) ; return $ scheduler ; } $ this -> setArguments ( $ arguments ) ; return $ this ; }
Define arguments for this schedule when it runs .
55,915
public function opts ( array $ options ) { if ( count ( $ this -> arguments ) == 0 ) { $ scheduler = App :: make ( get_called_class ( ) ) ; $ scheduler -> setOptions ( $ options ) ; return $ scheduler ; } $ this -> setOptions ( $ options ) ; return $ this ; }
Define options for this schedule when it runs .
55,916
public function commandNotRun ( ScheduledCommandInterface $ command , $ reason ) { if ( $ this -> optionReader -> isDebugMode ( ) ) { $ this -> output -> writeln ( ' <comment>' . $ command -> getName ( ) . '</comment>: ' . $ reason ) ; } }
Indicate why a command was not run
55,917
public function commandRun ( ScheduledCommandInterface $ command , $ runCommand ) { if ( $ this -> optionReader -> isDebugMode ( ) ) { $ this -> output -> writeln ( ' <info>' . $ command -> getName ( ) . '</info>: ' . $ runCommand ) ; } }
Indicate why a command has run
55,918
public function getDriver ( ) { $ class = $ this -> driverOptions [ 'class' ] ; if ( ! class_exists ( $ class ) ) { throw new \ ErrorException ( "Class '" . $ class . "' not found in " . get_class ( $ this ) ) ; } if ( $ class === self :: DATABASE_DRIVER ) { $ driver = $ this -> dbDriver ; $ driver -> setOptions ( $ th...
Return the driver
55,919
public function onKernelResponse ( FilterResponseEvent $ event ) { if ( $ this -> handleResponse && $ this -> http_code !== null ) { $ response = $ event -> getResponse ( ) ; $ response -> setStatusCode ( $ this -> http_code , $ this -> http_status ) ; } }
Rewrites the http code of the response
55,920
protected function checkIps ( $ requestedIp , $ ips ) { $ ips = ( array ) $ ips ; $ valid = false ; $ i = 0 ; while ( $ i < count ( $ ips ) && ! $ valid ) { $ valid = IpUtils :: checkIp ( $ requestedIp , $ ips [ $ i ] ) ; $ i ++ ; } return $ valid ; }
Checks if the requested ip is valid .
55,921
protected function registerDsnConfiguration ( $ options ) { if ( ! isset ( $ options [ 'table' ] ) ) { throw new InvalidArgumentException ( 'You need to define table for dsn use' ) ; } if ( ! isset ( $ options [ 'user' ] ) ) { throw new InvalidArgumentException ( 'You need to define user for dsn use' ) ; } if ( ! isset...
Load dsn configuration
55,922
public function setOptions ( $ options ) { $ this -> options = $ options ; if ( isset ( $ this -> options [ 'dsn' ] ) ) { $ this -> pdoDriver = new DsnQuery ( $ this -> options ) ; } else { if ( isset ( $ this -> options [ 'connection' ] ) ) { $ this -> pdoDriver = new DefaultQuery ( $ this -> doctrine -> getManager ( ...
Set options from configuration
55,923
public function isEndTime ( $ timeTtl ) { $ now = new \ DateTime ( 'now' ) ; $ accessTime = date ( "Y-m-d H:i:s." , filemtime ( $ this -> filePath ) ) ; $ accessTime = new \ DateTime ( $ accessTime ) ; $ accessTime -> modify ( sprintf ( '+%s seconds' , $ timeTtl ) ) ; if ( $ accessTime < $ now ) { return $ this -> crea...
Test if time to life is expired
55,924
public function setLocal ( $ local , $ value = null ) { if ( ! is_array ( $ local ) ) { $ local = array ( $ local => $ value ) ; } $ this -> _exports = array_merge ( $ this -> _exports , $ local ) ; }
Set local variables to be placed in the workers s scope .
55,925
public function cancelOperation ( ) { printf ( "Cancelling...\n" ) ; $ this -> _cancelled = true ; posix_kill ( $ this -> _pid , SIGKILL ) ; pcntl_signal_dispatch ( ) ; }
While a child process is running terminate it immediately .
55,926
public function start ( $ prompt , $ historyFile ) { readline_read_history ( $ historyFile ) ; declare ( ticks = 1 ) ; pcntl_signal ( SIGCHLD , SIG_IGN ) ; pcntl_signal ( SIGINT , array ( $ this , 'clear' ) , true ) ; if ( fread ( $ this -> _socket , 1 ) != EvalWorker :: READY ) { throw new \ RuntimeException ( 'EvalWo...
Start the client with an prompt and readline history path .
55,927
public function handle ( $ boris ) { $ args = getopt ( 'hvr:' , array ( 'help' , 'version' , 'require:' ) ) ; foreach ( $ args as $ option => $ value ) { switch ( $ option ) { case 'r' : case 'require' : $ this -> _handleRequire ( $ boris , $ value ) ; break ; case 'h' : case 'help' : $ this -> _handleUsageInfo ( ) ; b...
Accept the REPL object and perform any setup necessary from the CLI flags .
55,928
public function apply ( Boris $ boris ) { $ applied = false ; foreach ( $ this -> _searchPaths as $ path ) { if ( is_readable ( $ path ) ) { $ this -> _loadInIsolation ( $ path , $ boris ) ; $ applied = true ; $ this -> _files [ ] = $ path ; if ( ! $ this -> _cascade ) { break ; } } } return $ applied ; }
Searches for configuration files in the available search paths and applies them .
55,929
public function publishViews ( ) { $ sourceDir = __DIR__ . "/../../views/" ; $ destinationDir = base_path ( 'resources/views/infyom/generator-builder/' ) ; if ( file_exists ( $ destinationDir ) ) { $ answer = $ this -> ask ( 'Do you want to overwrite generator-builder? (y|N) :' , false ) ; if ( strtolower ( $ answer ) ...
Publishes views .
55,930
public function addClass ( $ value ) { if ( ! isset ( $ this -> attributeList [ 'class' ] ) || is_null ( $ this -> attributeList [ 'class' ] ) ) { $ this -> attributeList [ 'class' ] = array ( ) ; } $ this -> attributeList [ 'class' ] [ ] = $ value ; return $ this ; }
Add a class to classList
55,931
public function removeClass ( $ value ) { if ( ! is_null ( $ this -> attributeList [ 'class' ] ) ) { unset ( $ this -> attributeList [ 'class' ] [ array_search ( $ value , $ this -> attributeList [ 'class' ] ) ] ) ; } return $ this ; }
Remove a class from classList
55,932
public function getPrevious ( ) { $ prev = $ this ; $ find = false ; if ( ! is_null ( $ this -> parent ) ) { foreach ( $ this -> parent -> content as $ c ) { if ( $ c === $ this ) { $ find = true ; break ; } if ( ! $ find ) { $ prev = $ c ; } } } return $ prev ; }
Return previous element or itself
55,933
protected function contentToString ( ) { $ string = '' ; if ( ! is_null ( $ this -> content ) ) { foreach ( $ this -> content as $ c ) { $ string .= $ c -> toString ( ) ; } } return $ string ; }
return current list of content as a string
55,934
public function initPurifier ( $ defaultPurifierSerializerCache = null ) { if ( null !== $ this -> purifierConfig ) { $ HTMLPurifierConfig = $ this -> purifierConfig ; } else { $ HTMLPurifierConfig = \ HTMLPurifier_Config :: createDefault ( ) ; } if ( ! is_null ( $ defaultPurifierSerializerCache ) ) { $ HTMLPurifierCon...
Initializes HTMLPurifier with cache location .
55,935
protected function array_slice_cached ( & $ array , $ offset , $ length = null ) { static $ lastOffset = null ; static $ lastLength = null ; static $ cache = null ; if ( $ this -> resetCache === true ) { $ cache = null ; $ this -> resetCache = false ; } if ( $ cache !== null && $ lastLength === $ length && $ lastOffset...
Special array_slice function that caches its last request .
55,936
public function gitattributesAction ( Request $ request , $ repository , $ format = 'svg' ) { if ( $ request -> query -> get ( 'format' ) == 'plastic' ) { $ format = 'plastic' ; } $ this -> useCase = $ this -> container -> get ( 'use_case_badge_gitattributes' ) ; $ this -> imageFactory = $ this -> container -> get ( 'i...
. gitattributes action .
55,937
public function downloadsAction ( Request $ request , $ repository , $ type , $ format = 'svg' ) { $ this -> useCase = $ this -> container -> get ( 'use_case_badge_downloads' ) ; $ this -> imageFactory = $ this -> container -> get ( 'image_factory' ) ; if ( in_array ( $ request -> query -> get ( 'format' ) , $ this -> ...
Downloads action .
55,938
public function fetchByRepository ( $ repository ) { $ apiPackage = $ this -> client -> get ( $ repository ) ; if ( $ apiPackage && $ apiPackage instanceof ApiPackage ) { $ class = self :: $ packageClass ; return $ class :: createFromApi ( $ apiPackage ) ; } throw new UnexpectedValueException ( sprintf ( 'Impossible to...
Returns package if founded .
55,939
private function getBranchAliases ( ApiPackage \ Version $ version ) { $ extra = $ version -> getExtra ( ) ; if ( null !== $ extra && isset ( $ extra [ "branch-alias" ] ) && is_array ( $ extra [ "branch-alias" ] ) ) { return $ extra [ "branch-alias" ] ; } return null ; }
Get all the branch aliases .
55,940
public function licenseAction ( Request $ request , $ repository , $ format = 'svg' ) { $ this -> useCase = $ this -> container -> get ( 'use_case_badge_license' ) ; $ this -> imageFactory = $ this -> container -> get ( 'image_factory' ) ; if ( in_array ( $ request -> query -> get ( 'format' ) , $ this -> container -> ...
License action .
55,941
private function normalizeNumber ( $ number ) { if ( ! is_numeric ( $ number ) ) { throw new InvalidArgumentException ( 'Number expected' ) ; } $ number = floatval ( $ number ) ; if ( $ number < 0 ) { throw new InvalidArgumentException ( 'The number expected was >= 0' ) ; } return max ( $ number , 1 ) ; }
This function transform a number to a float value or raise an Exception .
55,942
public function incrementTotalAccess ( ) { $ this -> redis -> incr ( $ this -> keyTotal ) ; $ key = $ this -> createDailyKey ( $ this -> keyTotal ) ; $ this -> redis -> incr ( $ key ) ; $ key = $ this -> createMonthlyKey ( $ this -> keyTotal ) ; $ this -> redis -> incr ( $ key ) ; $ key = $ this -> createYearlyKey ( $ ...
Increment by one the total accesses .
55,943
public function incrementRepositoryAccess ( $ repository ) { $ this -> redis -> hincrby ( $ this -> concatenateKeys ( $ this -> keyHash , $ repository ) , self :: KEY_TOTAL , 1 ) ; $ key = $ this -> createDailyKey ( self :: KEY_TOTAL ) ; $ this -> redis -> hincrby ( $ this -> concatenateKeys ( $ this -> keyHash , $ rep...
Increment by one the repository accesses .
55,944
public function incrementRepositoryAccessType ( $ repository , $ type ) { $ this -> redis -> hincrby ( $ this -> concatenateKeys ( $ this -> keyHash , $ repository ) , $ type , 1 ) ; return $ this ; }
Increment by one the repository accesses type .
55,945
public function addReferer ( $ url ) { $ this -> redis -> zadd ( $ this -> concatenateKeys ( $ this -> keyList , self :: KEY_REFERER_SUFFIX ) , time ( ) , $ url ) ; return $ this ; }
Add the referrer to a subset .
55,946
private function createYearlyKey ( $ prefix , \ DateTime $ datetime = null ) { return sprintf ( "%s_%s" , $ prefix , $ this -> formatDate ( $ datetime , 'Y' ) ) ; }
Create the yearly key with prefix eg . total_2003
55,947
private function createMonthlyKey ( $ prefix , \ DateTime $ datetime = null ) { return sprintf ( "%s_%s" , $ prefix , $ this -> formatDate ( $ datetime , 'Y_m' ) ) ; }
Create the monthly key with prefix eg . total_2003_11
55,948
private function createDailyKey ( $ prefix , \ DateTime $ datetime = null ) { return sprintf ( "%s_%s" , $ prefix , $ this -> formatDate ( $ datetime , 'Y_m_d' ) ) ; }
Create the daily key with prefix eg . total_2003_11_29
55,949
private function formatDate ( \ DateTime $ datetime = null , $ format = 'Y_m_d' ) { if ( null == $ datetime ) { $ datetime = new \ DateTime ( 'now' ) ; } return $ datetime -> format ( $ format ) ; }
format a date .
55,950
public function serialize ( array $ table ) { $ buffer = '' ; foreach ( $ table as $ key => $ value ) { $ buffer .= $ this -> serializeShortString ( $ key ) ; $ buffer .= $ this -> serializeField ( $ value ) ; } return $ this -> serializeByteArray ( $ buffer ) ; }
Serialize an AMQP table .
55,951
private function serializeField ( $ value ) { if ( is_string ( $ value ) ) { return 'S' . $ this -> serializeLongString ( $ value ) ; } if ( is_int ( $ value ) ) { if ( $ value >= 0 ) { if ( $ value < 0x80 ) { return 'b' . $ this -> serializeSignedInt8 ( $ value ) ; } if ( $ value < 0x8000 ) { return 's' . $ this -> se...
Serialize a table or array field .
55,952
private function serializeArrayOrTable ( array $ array ) { $ assoc = false ; $ index = 0 ; $ values = [ ] ; foreach ( $ array as $ key => $ value ) { if ( $ assoc ) { $ values [ ] = $ this -> serializeShortString ( $ key ) . $ this -> serializeField ( $ value ) ; } elseif ( $ key === $ index ++ ) { $ values [ ] = $ thi...
Serialize a PHP array .
55,953
protected function requestFinished ( ) { $ this -> onResponse -> executeOne ( $ this , true ) ; $ this -> state = self :: STATE_ROOT ; $ this -> contentLength = - 1 ; $ this -> curChunkSize = null ; $ this -> chunked = false ; $ this -> eofTerminated = false ; $ this -> headers = [ ] ; $ this -> rawHeaders = null ; $ t...
Called when request is finished
55,954
public static function couldNotConnect ( ConnectionOptions $ options , $ description , \ Exception $ previous = null ) { return new self ( sprintf ( 'Unable to connect to AMQP broker [%s:%d], check connection options and network connectivity (%s).' , $ options -> getHost ( ) , $ options -> getPort ( ) , rtrim ( $ descr...
Create an exception that indicates a failure to establish a connection to an AMQP broker .
55,955
public static function notOpen ( ConnectionOptions $ options , \ Exception $ previous = null ) { return new self ( sprintf ( 'Unable to use connection to AMQP broker [%s:%d] because it is closed.' , $ options -> getHost ( ) , $ options -> getPort ( ) ) , 0 , $ previous ) ; }
Create an exception that indicates an attempt to use a connection that has already been closed .
55,956
public static function authenticationFailed ( ConnectionOptions $ options , \ Exception $ previous = null ) { return new self ( sprintf ( 'Unable to authenticate as "%s" on AMQP broker [%s:%d], check authentication credentials.' , $ options -> getUsername ( ) , $ options -> getHost ( ) , $ options -> getPort ( ) ) , 0 ...
Create an exception that indicates that the credentials specified in the connection options are incorrect .
55,957
public static function authorizationFailed ( ConnectionOptions $ options , \ Exception $ previous = null ) { return new self ( sprintf ( 'Unable to access vhost "%s" as "%s" on AMQP broker [%s:%d], check permissions.' , $ options -> getVhost ( ) , $ options -> getUsername ( ) , $ options -> getHost ( ) , $ options -> g...
Create an exception that indicates that the credentials specified in the connection options do not grant access to the requested AMQP virtual host .
55,958
public static function heartbeatTimedOut ( ConnectionOptions $ options , $ heartbeatInterval , \ Exception $ previous = null ) { return new self ( sprintf ( 'The AMQP connection with broker [%s:%d] has timed out, ' . 'the last heartbeat was received over %d seconds ago.' , $ options -> getHost ( ) , $ options -> getPor...
Create an exception that indicates that the broker has failed to send any data for a period longer than the heartbeat interval .
55,959
protected function escapeList ( $ list ) { $ result = [ ] ; foreach ( $ list as $ v ) { if ( ! is_array ( $ v ) ) { $ result [ ] = $ v ; continue ; } $ result [ ] = $ this -> escapeList ( $ v ) ; } return '(' . implode ( ' ' , $ result ) . ')' ; }
escape a list with literals or lists
55,960
public function removeMessage ( $ cb , $ uid ) { $ this -> onResponse -> push ( $ cb ) ; $ this -> store ( [ self :: FLAG_DELETED ] , $ uid , null , '+' , true , self :: TAG_DELETEMESSAGE ) ; }
Remove a message from server .
55,961
public function gracefulShutdown ( ) { if ( $ this -> finished ) { return ! $ this -> writing ; } $ this -> logoff ( ) ; $ this -> finish ( ) ; return false ; }
Called when the worker is going to shutdown
55,962
protected function auth ( ) { if ( $ this -> state !== self :: CONN_STATE_GOT_INITIAL_PACKET ) { return ; } if ( $ this -> pool -> config -> authtype -> value === 'md5' ) { $ this -> challenge ( function ( $ conn , $ challenge ) { $ packet = "Action: Login\r\n" . "AuthType: MD5\r\n" . "Username: " . $ this -> username ...
Send authentication packet
55,963
protected function implodeParams ( array $ params ) { $ s = '' ; foreach ( $ params as $ header => $ value ) { $ s .= trim ( $ header ) . ": " . trim ( $ value ) . "\r\n" ; } return $ s ; }
Generate AMI packet string from associative array provided
55,964
public function readFromString ( $ chunk , $ final = true ) { $ this -> add ( $ chunk ) ; $ this -> readed += mb_orig_strlen ( $ chunk ) ; if ( $ final ) { $ this -> onRead ( ) ; } }
Append string to input buffer
55,965
public function getChunkString ( ) { if ( ! $ this -> curChunkSize ) { return false ; } $ chunk = $ this -> read ( $ this -> curChunkSize ) ; $ this -> curChunkSize = null ; return $ chunk ; }
Get current upload chunk as string
55,966
public function writeChunkToFd ( $ fd , $ cb = null ) { return false ; if ( ! $ this -> curChunkSize ) { return false ; } $ this -> write ( $ fd , $ this -> curChunkSize ) ; $ this -> curChunkSize = null ; return true ; }
Write current upload chunk to file descriptor
55,967
public function sendfile ( $ path , $ cb , $ pri = EIO_PRI_DEFAULT ) { if ( $ this -> state === self :: STATE_FINISHED ) { return false ; } try { $ this -> header ( 'Content-Type: ' . MIME :: get ( $ path ) ) ; } catch ( RequestHeadersAlreadySent $ e ) { } if ( $ this -> upstream -> checkSendfileCap ( ) ) { FileSystem ...
Output whole contents of file
55,968
public function checkIfReady ( ) { if ( ! $ this -> attrs -> paramsDone || ! $ this -> attrs -> inputDone ) { return false ; } if ( isset ( $ this -> appInstance -> passphrase ) ) { if ( ! isset ( $ this -> attrs -> server [ 'PASSPHRASE' ] ) || ( $ this -> appInstance -> passphrase !== $ this -> attrs -> server [ 'PASS...
Called to check if Request is ready
55,969
public function ensureSentHeaders ( ) { if ( $ this -> headers_sent ) { return true ; } if ( isset ( $ this -> headers [ 'STATUS' ] ) ) { $ h = ( isset ( $ this -> attrs -> noHttpVer ) && ( $ this -> attrs -> noHttpVer ) ? 'Status: ' : $ this -> attrs -> server [ 'SERVER_PROTOCOL' ] ) . ' ' . $ this -> headers [ 'STATU...
Ensure that headers are sent
55,970
public function status ( $ code = 200 ) { if ( ! isset ( self :: $ codes [ $ code ] ) ) { return false ; } $ this -> header ( $ code . ' ' . self :: $ codes [ $ code ] ) ; return true ; }
Send HTTP - status
55,971
public function headersSent ( & $ file , & $ line ) { $ file = $ this -> headers_sent_file ; $ line = $ this -> headers_sent_line ; return $ this -> headers_sent ; }
Checks if headers have been sent
55,972
public function setcookie ( $ name , $ value = '' , $ maxage = 0 , $ path = '' , $ domain = '' , $ secure = false , $ HTTPOnly = false ) { $ this -> header ( 'Set-Cookie: ' . $ name . '=' . rawurlencode ( $ value ) . ( empty ( $ domain ) ? '' : '; Domain=' . $ domain ) . ( empty ( $ maxage ) ? '' : '; Max-Age=' . $ max...
Set the cookie
55,973
public static function parseSize ( $ value ) { $ l = substr ( $ value , - 1 ) ; if ( $ l === 'b' || $ l === 'B' ) { return ( ( int ) substr ( $ value , 0 , - 1 ) ) ; } if ( $ l === 'k' ) { return ( ( int ) substr ( $ value , 0 , - 1 ) * 1000 ) ; } if ( $ l === 'K' ) { return ( ( int ) substr ( $ value , 0 , - 1 ) * 102...
Converts human - readable representation of size to number of bytes
55,974
public function onUploadFileStart ( $ in ) { $ this -> freezeInput ( ) ; FileSystem :: tempnam ( ini_get ( 'upload_tmp_dir' ) , 'php' , function ( $ fp ) use ( $ in ) { if ( ! $ fp ) { $ in -> curPart [ 'fp' ] = false ; $ in -> curPart [ 'error' ] = UPLOAD_ERR_NO_TMP_DIR ; } else { $ in -> curPart [ 'fp' ] = $ fp ; $ i...
Called when file upload started
55,975
public function onUploadFileChunk ( $ in , $ last = false ) { if ( $ in -> curPart [ 'error' ] !== UPLOAD_ERR_OK ) { return ; } $ cb = function ( $ fp , $ result ) use ( $ last , $ in ) { if ( $ last ) { unset ( $ in -> curPart [ 'fp' ] ) ; } $ this -> unfreezeInput ( ) ; } ; if ( $ in -> writeChunkToFd ( $ in -> curPa...
Called when chunk of incoming file has arrived
55,976
public function isUploadedFile ( $ path ) { if ( ! $ path ) { return false ; } if ( mb_orig_strpos ( $ path , $ this -> getUploadTempDir ( ) . '/' ) !== 0 ) { return false ; } foreach ( $ this -> attrs -> files as $ file ) { if ( $ file [ 'tmp_name' ] === $ path ) { return true ; } } return false ; }
Tells whether the file was uploaded via HTTP POST
55,977
public function moveUploadedFile ( $ filename , $ dest ) { if ( ! $ this -> isUploadedFile ( $ filename ) ) { return false ; } return FileSystem :: rename ( $ filename , $ dest ) ; }
Moves an uploaded file to a new location
55,978
public function readBodyFile ( ) { if ( ! isset ( $ this -> attrs -> server [ 'REQUEST_BODY_FILE' ] ) ) { return false ; } FileSystem :: readfileChunked ( $ this -> attrs -> server [ 'REQUEST_BODY_FILE' ] , function ( $ file , $ success ) { $ this -> attrs -> inputDone = true ; if ( $ this -> sleepTime === 0 ) { $ this...
Read request body from the file given in REQUEST_BODY_FILE parameter
55,979
protected function postFinishHandler ( $ cb = null ) { if ( ! $ this -> headers_sent ) { $ this -> out ( '' ) ; } $ this -> sendfp = null ; if ( isset ( $ this -> attrs -> files ) ) { foreach ( $ this -> attrs -> files as $ f ) { if ( isset ( $ f [ 'tmp_name' ] ) ) { FileSystem :: unlink ( $ f [ 'tmp_name' ] ) ; } } } ...
Called after request finish
55,980
public function put ( $ key , $ value , $ ttl = null ) { $ k = $ this -> hash ( $ key ) ; if ( isset ( $ this -> cache [ $ k ] ) ) { $ item = $ this -> cache [ $ k ] ; $ item -> setValue ( $ value ) ; if ( $ ttl !== null ) { $ item -> expire = microtime ( true ) + $ ttl ; } return $ item ; } $ item = new Item ( $ value...
Puts element in cache
55,981
public function get ( $ key ) { $ k = $ this -> hash ( $ key ) ; if ( ! isset ( $ this -> cache [ $ k ] ) ) { return null ; } $ item = $ this -> cache [ $ k ] ; if ( isset ( $ item -> expire ) ) { if ( microtime ( true ) >= $ item -> expire ) { unset ( $ this -> cache [ $ k ] ) ; return null ; } } return $ item ; }
Gets element by key
55,982
public function sub ( $ id , $ obj , $ cb ) { if ( ! isset ( $ this -> events [ $ id ] ) ) { return false ; } return $ this -> events [ $ id ] -> sub ( $ obj , $ cb ) ; }
Subcribe to event
55,983
public function unsub ( $ id , $ obj ) { if ( ! isset ( $ this -> events [ $ id ] ) ) { return false ; } return $ this -> events [ $ id ] -> unsub ( $ obj ) ; }
Unsubscribe object from event
55,984
public function unsubFromAll ( $ obj ) { foreach ( $ this -> events as $ event ) { $ event -> unsub ( $ obj ) ; } return true ; }
Unsubscribe object from all events
55,985
public function isEnabled ( ) { return isset ( $ this -> config -> enable -> value ) && $ this -> config -> enable -> value ; }
Returns whether if this application is enabled
55,986
public function broadcastCall ( $ method , $ args = [ ] , $ cb = null ) { return Daemon :: $ process -> IPCManager -> sendBroadcastCall ( '\\' . get_class ( $ this ) . ( $ this -> name !== '' ? ':' . $ this -> name : '' ) , $ method , $ args , $ cb ) ; }
Send broadcast RPC You can override it
55,987
public function singleCall ( $ method , $ args = [ ] , $ cb = null ) { return Daemon :: $ process -> IPCManager -> sendSingleCall ( '\\' . get_class ( $ this ) . ( $ this -> name !== '' ? ':' . $ this -> name : '' ) , $ method , $ args , $ cb ) ; }
Send RPC executed once in any worker You can override it
55,988
public function directCall ( $ workerId , $ method , $ args = [ ] , $ cb = null ) { return Daemon :: $ process -> IPCManager -> sendDirectCall ( $ workerId , '\\' . get_class ( $ this ) . ( $ this -> name !== '' ? ':' . $ this -> name : '' ) , $ method , $ args , $ cb ) ; }
Send RPC executed once in certain worker You can override it
55,989
public function beginRequest ( $ req , $ upstream ) { if ( ! $ this -> requestClass ) { return false ; } $ className = $ this -> requestClass ; return new $ className ( $ this , $ upstream , $ req ) ; }
Create Request instance
55,990
public function handleStatus ( $ ret ) { if ( $ ret === self :: EVENT_CONFIG_UPDATED ) { $ this -> onConfigUpdated ( ) ; return true ; } elseif ( $ ret === self :: EVENT_GRACEFUL_SHUTDOWN ) { return $ this -> onShutdown ( true ) ; } elseif ( $ ret === self :: EVENT_SHUTDOWN ) { return $ this -> onShutdown ( ) ; } retur...
Handle the worker status
55,991
public function flush ( ) { if ( $ this -> pollMode === null ) { return ; } if ( $ this -> flushing ) { return ; } $ bsize = sizeof ( $ this -> buffer ) ; $ fbsize = sizeof ( $ this -> framesBuffer ) ; if ( $ bsize === 0 && $ fbsize === 0 ) { return ; } $ this -> flushing = true ; if ( in_array ( 'one-by-one' , $ this ...
Flushes buffered packets
55,992
protected function getCookieStr ( $ name ) { return \ PHPDaemon \ HTTPRequest \ Generic :: getString ( $ this -> attrs -> cookie [ $ name ] ) ; }
Get cookie by name
55,993
public function onShutdown ( $ graceful = false ) { if ( $ this -> pool ) { return $ this -> pool -> onShutdown ( $ graceful ) ; } return true ; }
Called when application instance is going to shutdown .
55,994
protected function checkPassword ( $ pass = '' ) { if ( ! hash_equals ( $ this -> pool -> config -> passphrase -> value , $ pass ) ) { -- $ this -> authTries ; if ( 0 === $ this -> authTries ) { $ this -> disconnect ( ) ; } else { $ this -> write ( 'Wrong password. Please, try again: ' ) ; } } else { $ this -> writeln ...
Let s check the password
55,995
protected function _computeFinalKey ( $ key1 , $ key2 , $ data ) { if ( mb_orig_strlen ( $ data ) < 8 ) { Daemon :: $ process -> log ( get_class ( $ this ) . '::' . __METHOD__ . ' : Invalid handshake data for client "' . $ this -> addr . '"' ) ; return false ; } return md5 ( $ this -> _computeKey ( $ key1 ) . $ this ->...
Computes final key for Sec - WebSocket .
55,996
protected function _computeKey ( $ key ) { $ spaces = 0 ; $ digits = '' ; for ( $ i = 0 , $ s = mb_orig_strlen ( $ key ) ; $ i < $ s ; ++ $ i ) { $ c = mb_orig_substr ( $ key , $ i , 1 ) ; if ( $ c === "\x20" ) { ++ $ spaces ; } elseif ( ctype_digit ( $ c ) ) { $ digits .= $ c ; } } if ( $ spaces > 0 ) { $ result = ( f...
Computes key for Sec - WebSocket .
55,997
public function feed ( $ buffer , & $ requiredBytes = 0 ) { $ this -> buffer .= $ buffer ; $ availableBytes = \ strlen ( $ this -> buffer ) ; if ( $ availableBytes < $ this -> requiredBytes ) { $ requiredBytes = $ this -> requiredBytes ; return null ; } if ( $ this -> requiredBytes === self :: MINIMUM_FRAME_SIZE ) { $ ...
Retrieve the next frame from the internal buffer .
55,998
public function onUpdate ( $ old ) { if ( ! Daemon :: $ process instanceof Master || ( Daemon :: $ config -> autoreload -> value === 0 ) || ! $ old ) { return ; } $ e = explode ( ';' , $ old ) ; foreach ( $ e as $ path ) { Daemon :: $ process -> fileWatcher -> rmWatch ( $ path , [ Daemon :: $ process , 'sighup' ] ) ; }...
Called when entry is updated
55,999
public function execute ( ) { if ( ! count ( $ this -> stack ) ) { foreach ( $ this -> listeners as $ cb ) { $ cb ( $ this -> pool ) ; } return ; } $ params = $ this -> getParams ( ) ; $ params [ ] = function ( $ redis ) { foreach ( $ this -> listeners as $ cb ) { $ cb ( $ redis ) ; } } ; $ this -> pool -> eval ( ... $...
Runs the stack of commands