idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
16,800
public function stopLiveRecording ( $ recordingName ) { $ uri = "recordings/live/$recordingName/stop" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Stop a live recording and store it .
16,801
public function getEndpoints ( ) { $ uri = 'endpoints' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ endpoints = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ endpoint ) { $ endpoints [ ] = new Endpoint ( $ this -> client , $ endpoint ) ; } return $ endpoints ; ...
List all endpoints .
16,802
public function sendMessage ( $ to , $ from , $ body , $ variables = array ( ) ) { $ uri = 'endpoints/sendMessage' ; try { $ this -> client -> getEndpoint ( ) -> put ( $ uri , [ 'form_params' => [ 'to' => $ to , 'from' => $ from , 'body' => $ body , 'variables' => array_map ( 'strval' , $ variables ) , ] ] ) ; } catch ...
Send a message to some technology URI or endpoint .
16,803
public function getEndpointsByTech ( $ tech ) { $ uri = "endpoints/$tech" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } $ endpoints = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as...
List available endoints for a given endpoint technology .
16,804
public function getEndpointByTechAndResource ( $ tech , $ resource ) { $ uri = "endpoints/$tech/$resource" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Endpoint ( $ this -> client , \ GuzzleHttp \ ...
Details for an endpoint .
16,805
public function getChannels ( ) { $ uri = 'channels' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ channels = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ channel ) { $ channels [ ] = new Channel ( $ this -> client , $ channel ) ; } return $ channels ; }
List all active channels in Asterisk .
16,806
public function getChannel ( $ channelId ) { $ uri = "channels/$channelId" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Channel ( $ this -> client , \ GuzzleHttp \ json_decode ( $ response -> getBo...
Channel details .
16,807
public function redirect ( $ channelId , $ endpoint ) { $ uri = "channels/$channelId/redirect" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'endpoint' => $ endpoint ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Redirect the channel to a different location .
16,808
public function mute ( $ channelId , $ direction ) { $ uri = "channels/$channelId/mute" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'direction' => $ direction , ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Mute a channel .
16,809
public function unmute ( $ channelId , $ direction ) { $ uri = "channels/$channelId/mute?direction=" . \ GuzzleHttp \ json_encode ( $ direction ) ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Unmute a channel .
16,810
public function hold ( $ channelId ) { $ uri = "channels/$channelId/hold" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Hold a channel .
16,811
public function unhold ( $ channelId ) { $ uri = "channels/$channelId/hold" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Remove a channel from hold .
16,812
protected function getResponseValue ( $ propertyName , $ class = null , AriClient $ client = null ) { if ( property_exists ( $ this -> response , $ propertyName ) ) { if ( $ class !== null ) { if ( $ client instanceof AriClient ) { return new $ class ( $ client , $ this -> response -> { $ propertyName } ) ; } else { re...
Get the response value or object depending on which type of class .
16,813
public function getObject ( $ configClass , $ objectType , $ id ) { $ uri = "asterisk/config/dynamic/$configClass/$objectType/$id" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } $ configTuples = [ ] ; foreach (...
Retrieve a dynamic configuration object .
16,814
public function updateObject ( $ configClass , $ objectType , $ id , $ fields ) { $ uri = "asterisk/config/dynamic/$configClass/$objectType/$id" ; try { $ response = $ this -> client -> getEndpoint ( ) -> put ( $ uri , [ 'form_params' => [ 'fields' => array_map ( 'strval' , $ fields ) ] ] ) ; } catch ( RequestException...
Create or update a dynamic configuration object .
16,815
public function deleteObject ( $ configClass , $ objectType , $ id ) { $ uri = "asterisk/config/dynamic/$configClass/$objectType/$id" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Delete a dynamic configuration object .
16,816
public function getInfo ( $ only = null ) { if ( empty ( $ only ) ) { $ uri = 'asterisk/info' ; } else { $ uri = "asterisk/info?only=$only" ; } $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; return new AsteriskInfo ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ) ; }
Gets Asterisk system information .
16,817
public function listModules ( ) { $ uri = 'asterisk/modules' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ modules = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ module ) { $ modules [ ] = new Module ( $ module ) ; } return $ modules ; }
List Asterisk modules .
16,818
public function getModule ( $ moduleName ) { $ uri = "asterisk/module/$moduleName" ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; return new Module ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ) ; }
Get Asterisk module information .
16,819
public function listLogChannels ( ) { $ uri = 'asterisk/logging' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ logChannels = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ logChannel ) { $ logChannels [ ] = new Module ( $ logChannel ) ; } return $ logChannels ; }
Gets Asterisk log channel information .
16,820
public function addLog ( $ logChannelName , $ configuration ) { $ uri = "asterisk/logging/$logChannelName" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'configuration' => $ configuration ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Adds a log channel .
16,821
public function deleteLog ( $ logChannelName ) { $ uri = "asterisk/logging/$logChannelName" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Deletes a log channel .
16,822
public function rotateLog ( $ logChannelName ) { $ uri = "asterisk/logging/$logChannelName" ; try { $ this -> client -> getEndpoint ( ) -> put ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Rotates a log channel .
16,823
public function getGlobalVar ( $ variable ) { $ uri = "asterisk/variable?variable=$variable" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Variable ( \ GuzzleHttp \ json_decode ( $ response -> getBo...
Get the value of a global variable .
16,824
public function setGlobalVar ( $ variable , $ value = null ) { $ uri = 'asterisk/variable' ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'variable' => $ variable , 'value' => $ value ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Set the value of a global variable .
16,825
public function getPlayback ( $ playbackId ) { $ uri = "playbacks/$playbackId" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Playback ( $ this -> client , \ GuzzleHttp \ json_decode ( $ response -> ...
Get a playback s details .
16,826
public function stopPlayback ( $ playbackId ) { $ uri = "playbacks/$playbackId" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Stop a playback .
16,827
public function controlPlayback ( $ playbackId , $ operation ) { $ uri = "playbacks/$playbackId/control" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'operation' => $ operation , ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Control a playback .
16,828
public function connect ( $ ariAddress , $ amiAddress = null , $ streamOptions = [ ] , $ clientOptions = [ ] ) { $ this -> ariClient -> connect ( $ ariAddress , $ streamOptions , $ clientOptions ) ; $ this -> wsClient = $ this -> ariClient -> getWsClient ( ) ; $ this -> stasisApplicationName = $ this -> ariClient -> ge...
Connect to ARI and optionally AMI
16,829
public function stop ( ) { $ deferred = new Deferred ( ) ; $ onStop = $ this -> onStop ; $ onStop ( ) -> then ( function ( ) use ( & $ deferred ) { $ this -> ariClient -> onClose ( function ( ) use ( & $ deferred ) { $ this -> eventLoop -> stop ( ) ; $ deferred -> resolve ( ) ; } ) ; $ this -> wsClient -> close ( ) ; }...
Disconnect and stop the event loop
16,830
public function getSounds ( ) { $ uri = 'sounds' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ sounds = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ sound ) { $ sounds [ ] = new Sound ( $ sound ) ; } return $ sounds ; }
List all sounds .
16,831
public function getSound ( $ soundId ) { $ uri = "sounds/$soundId" ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; return new Sound ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ) ; }
Get a sound s details .
16,832
public function connect ( $ address , array $ streamOptions = [ ] , $ httpOptions = [ ] ) { $ components = parse_url ( $ address ) ; $ scheme = $ components [ 'scheme' ] ; $ host = $ components [ 'host' ] ; $ port = $ components [ 'port' ] ; $ path = $ components [ 'path' ] ; $ query = $ components [ 'query' ] ; $ quer...
Connect to ARI .
16,833
public function connect ( $ address ) { $ factory = new Factory ( $ this -> eventLoop ) ; return $ factory -> createClient ( $ address ) -> then ( function ( Client $ client ) { $ this -> amiClient = $ client ; $ this -> actionSender = new ActionSender ( $ client ) ; $ this -> actionSender -> events ( true ) ; $ client...
Connect to AMI and start emitting events .
16,834
public function getUsers ( $ opts = [ ] ) { $ query = '' ; if ( isset ( $ opts [ 'search' ] ) ) $ query .= '?search=' . $ opts [ 'search' ] ; $ endpoint = '/users' . $ query ; return $ this -> doRequest ( 'GET' , $ endpoint ) ; }
Get all registered users
16,835
public function updateUser ( $ username , $ password , $ name = false , $ email = false , $ groups = false ) { $ endpoint = '/users/' . $ username ; return $ this -> doRequest ( 'PUT' , $ endpoint , compact ( 'username' , 'password' , 'name' , 'email' , 'groups' ) ) ; }
Updates an OpenFire user
16,836
public function addToRoster ( $ username , $ jid , $ name = false , $ subscriptionType = false ) { $ endpoint = '/users/' . $ username . '/roster' ; return $ this -> doRequest ( 'POST' , $ endpoint , compact ( 'jid' , 'name' , 'subscriptionType' ) ) ; }
Adds to this OpenFire user s roster
16,837
public function deleteFromRoster ( $ username , $ jid ) { $ endpoint = '/users/' . $ username . '/roster/' . $ jid ; return $ this -> doRequest ( 'DELETE' , $ endpoint , $ jid ) ; }
Removes from this OpenFire user s roster
16,838
public function updateRoster ( $ username , $ jid , $ nickname = false , $ subscriptionType = false ) { $ endpoint = '/users/' . $ username . '/roster/' . $ jid ; return $ this -> doRequest ( 'PUT' , $ endpoint , $ jid , compact ( 'jid' , 'username' , 'subscriptionType' ) ) ; }
Updates this OpenFire user s roster
16,839
public function getBridges ( ) { $ uri = 'bridges' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ bridges = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ bridge ) { $ bridges [ ] = new Bridge ( $ this -> client , $ bridge ) ; } return $ bridges ; }
List all active bridges in Asterisk .
16,840
public function createBridge ( $ bridgeId , $ type , $ name ) { $ uri = 'bridges' ; $ response = $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'bridgeId' => $ bridgeId , 'type' => $ type , 'name' => $ name , ] ] ) ; return new Bridge ( $ this -> client , \ GuzzleHttp \ json_decode ( $ respo...
Create a new bridge . This bridge persists until it has been shut down or Asterisk has been shut down .
16,841
public function getBridge ( $ bridgeId ) { $ uri = "bridges/$bridgeId" ; try { $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } return new Bridge ( $ this -> client , \ GuzzleHttp \ json_decode ( $ response -> getBody ( ...
Get bridge details .
16,842
public function deleteBridge ( $ bridgeId ) { $ uri = "bridges/$bridgeId" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Shut down a bridge . If any channels are in this bridge they will be removed and resume whatever they were doing beforehand .
16,843
public function removeChannel ( $ bridgeId , $ channel ) { $ uri = "bridges/$bridgeId/removeChannel" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri , [ 'form_params' => [ 'channel' => $ channel , ] ] ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Remove a channel from a bridge .
16,844
public function setVideoSource ( $ id , $ channelId ) { $ uri = "bridges/$id/videoSource/$channelId" ; try { $ this -> client -> getEndpoint ( ) -> post ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Set a channel as the video source in a multi - party mixing bridge . This operation has no effect on bridges with two or fewer participants .
16,845
public function clearVideoSource ( $ id ) { $ uri = "bridges/$id/videoSource" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Removes any explicit video source in a multi - party mixing bridge . This operation has no effect on bridges with two or fewer participants . When no explicit video source is set talk detection will be used to determine the active video stream .
16,846
public function getDeviceStates ( ) { $ uri = 'deviceStates' ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; $ deviceStates = [ ] ; foreach ( \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) as $ deviceState ) { $ deviceStates [ ] = new DeviceState ( $ this -> client , $ deviceState ) ; } ...
List all ARI controlled device states .
16,847
public function getDeviceState ( $ deviceName ) { $ uri = "deviceStates/$deviceName" ; $ response = $ this -> client -> getEndpoint ( ) -> get ( $ uri ) ; return new DeviceState ( $ this -> client , \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) ) ) ; }
Retrieve the current state of a device .
16,848
public function deleteDeviceState ( $ deviceName ) { $ uri = "deviceStates/$deviceName" ; try { $ this -> client -> getEndpoint ( ) -> delete ( $ uri ) ; } catch ( RequestException $ e ) { $ this -> processRequestException ( $ e ) ; } }
Destroy a device - state controlled by ARI .
16,849
public static function createByName ( $ name ) { $ constants = static :: getConstantsByName ( ) ; if ( ! array_key_exists ( $ name , $ constants ) ) { throw new UnexpectedValueException ( "Name '{$name}' is not exists in the enum constants list " . get_called_class ( ) ) ; } return new static ( $ constants [ $ name ] )...
Creates a new type instance using the name of a value .
16,850
public static function getLabel ( $ value ) { $ list = static :: $ list ; if ( isset ( $ list [ $ value ] ) ) { return Yii :: t ( static :: $ messageCategory , $ list [ $ value ] ) ; } return null ; }
Get label by value
16,851
public function assertThrowsWithMessage ( $ throws , $ message , callable $ fn ) { $ result = $ this -> getTestResultObject ( ) ; if ( is_array ( $ throws ) ) { $ message = ( $ throws [ 1 ] ) ? $ throws [ 1 ] : false ; $ throws = $ throws [ 0 ] ; } $ message = strtolower ( $ message ) ; try { call_user_func ( $ fn ) ; ...
Asserts that callback throws an exception with a message
16,852
protected function createEnvProductionFile ( $ env_file , $ env_production_file , $ dbSocket , $ dbName ) { if ( ! file_exists ( $ env_file ) ) { $ this -> myCommand -> error ( 'Cannot find ".env" file to import the existing options.' ) ; return ; } if ( file_exists ( $ env_production_file ) ) { $ overwrite = $ this ->...
Creates a . env . production file based on the existing . env file .
16,853
protected function createEnvLocalFile ( $ env_file , $ env_local_file , $ dbHost , $ dbName ) { if ( ! file_exists ( $ env_file ) ) { $ this -> myCommand -> error ( 'Cannot find ".env" file to import the existing options.' ) ; return ; } if ( file_exists ( $ env_local_file ) ) { $ overwrite = $ this -> myCommand -> con...
Creates a . env . local file based on the existing . env file .
16,854
protected function processFile ( $ filePath , $ processors ) { $ contents = file_get_contents ( $ filePath ) ; $ processed = $ contents ; foreach ( $ processors as $ processor ) { $ processed = $ this -> $ processor ( $ processed ) ; } if ( $ processed === $ contents ) { return ; } $ this -> backupFile ( $ filePath ) ;...
Processes a given file with given processors .
16,855
protected function replaceAppClass ( $ contents ) { $ modified = str_replace ( 'Illuminate\Foundation\Application' , 'Shpasser\GaeSupportL5\Foundation\Application' , $ contents ) ; if ( $ contents !== $ modified ) { $ this -> myCommand -> info ( 'Replaced the application class in "bootstrap/app.php".' ) ; } return $ mo...
Processor function . Replaces the Laravel application class with the one compatible with GAE .
16,856
protected function replaceLaravelServiceProviders ( $ contents ) { $ strings = [ 'Illuminate\Mail\MailServiceProvider' , 'Illuminate\Queue\QueueServiceProvider' ] ; $ replacements = [ 'Shpasser\GaeSupportL5\Mail\MailServiceProvider' , 'Shpasser\GaeSupportL5\Queue\QueueServiceProvider' ] ; $ modified = str_replace ( $ s...
Processor function . Replaces the Laravel service providers with GAE compatible ones .
16,857
protected function setLogHandler ( $ contents ) { $ expression = "/'log'.*=>((?!env\('APP_LOG').)*'\b.+?\b'\)?/" ; $ replacement = "'log' => env('APP_LOG', 'single')" ; $ modified = preg_replace ( $ expression , $ replacement , $ contents ) ; if ( $ contents !== $ modified ) { $ this -> myCommand -> info ( 'Set the log...
Processor function . Sets the syslog log handler for a Laravel GAE app .
16,858
protected function preprocessWindowsPaths ( $ contents ) { $ expression = "/'([A-Za-z]:)?((\\\\|\/)[^\\/:*?\"\'<>|\r\n]*)*'/" ; $ paths = array ( ) ; preg_match_all ( $ expression , $ contents , $ paths ) ; $ modified = $ contents ; foreach ( $ paths [ 0 ] as $ path ) { $ normalizedPath = str_replace ( '\\\\' , '/' , $...
Processor function . Pre - processes windows paths .
16,859
protected function fixCachedConfig ( $ contents ) { $ app_path = app_path ( ) ; $ storage_path = storage_path ( ) ; $ base_path = base_path ( ) ; $ replaceFunction = 'str_replace' ; if ( $ this -> isRunningOnWindows ( ) ) { $ contents = $ this -> preprocessWindowsPaths ( $ contents ) ; $ app_path = str_replace ( '\\' ,...
Fixes the paths in the cached config file .
16,860
protected function generatePhpIni ( $ appId , $ bucketId , $ filePath ) { if ( file_exists ( $ filePath ) ) { $ overwrite = $ this -> myCommand -> confirm ( 'Overwrite the existing "php.ini" file?' , false ) ; if ( ! $ overwrite ) { return ; } } $ storageBucket = "{$appId}.appspot.com" ; if ( $ bucketId !== null ) { $ ...
Generates a php . ini file for a GAE app .
16,861
protected function restoreFile ( $ filePath , $ backupPath , $ clean = true ) { if ( file_exists ( $ backupPath ) ) { copy ( $ backupPath , $ filePath ) ; if ( $ clean ) { unlink ( $ backupPath ) ; } } return $ backupPath ; }
Restores a file from its backup copy .
16,862
public function read ( $ file ) { $ this -> filePath = $ file ; $ this -> config = parse_ini_file ( $ this -> filePath ) ; }
Reads a INI file and parses its values into an array .
16,863
public function write ( $ file = "" ) { $ iniString = $ this -> generateIniString ( $ this -> config ) ; file_put_contents ( $ file ? $ file : $ this -> filePath , $ iniString ) ; }
Writes the configuration data back to the INI file .
16,864
protected function generateIniString ( $ array ) { $ iniString = "" ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ iniString .= "[{$key}]" . PHP_EOL ; $ iniString .= $ this -> generateIniString ( $ value ) ; } else { $ iniString .= "{$key}={$value}" . PHP_EOL ; } } return $ iniString ; }
Generates an INI string from a given associative array .
16,865
public function execute ( Request $ request ) { $ command = $ request -> input ( 'command' ) ; if ( $ command === '' ) { $ command = 'list' ; } $ output = new BufferedOutput ; Artisan :: handle ( new StringInput ( $ command . self :: NON_INTERACTIVE ) , $ output ) ; $ results = $ output -> fetch ( ) ; return view ( 'ga...
Executes a command submitted from Artisan Console page .
16,866
public function fire ( ) { $ dbSocket = $ this -> option ( 'db-socket' ) ; $ dbHost = $ this -> option ( 'db-host' ) ; $ dbName = $ this -> option ( 'db-name' ) ; if ( ! is_null ( $ dbName ) && ( is_null ( $ dbSocket ) && is_null ( $ dbHost ) ) ) { $ this -> error ( "Option '--db-name' requires at least one of: '--db-s...
Execute the console command . For backward compatibility .
16,867
private function generateCommand ( $ name , \ ReflectionMethod $ method , $ token = null ) { $ methodName = $ this -> transformer -> transform ( $ method -> getName ( ) ) ; $ command = new Command ( strtolower ( $ name . ':' . $ methodName ) ) ; $ factory = DocBlockFactory :: createInstance ( ) ; $ docBlock = $ factory...
Creates a Command based on an Api Method .
16,868
private function buildDefinition ( \ ReflectionMethod $ method , DocBlock $ docBlock , $ token = null ) { $ definition = new InputDefinition ( ) ; foreach ( $ docBlock -> getTags ( ) as $ tag ) { if ( $ tag instanceof DocBlock \ Tags \ Param ) { $ tagsDescription [ $ tag -> getVariableName ( ) ] = $ tag -> getDescripti...
Builds the Input Definition based upon Api Method Parameters .
16,869
private function createCode ( $ name , \ ReflectionMethod $ method ) { return function ( InputInterface $ input , OutputInterface $ output ) use ( $ name , $ method ) { $ client = new Client ( [ ] , null , $ output ) ; if ( $ input -> getOption ( 'token' ) ) { $ client -> authorize ( $ input -> getOption ( 'token' ) ) ...
Creates the command execution code .
16,870
public function activity ( $ target , $ text , $ suggestedActions = [ ] ) { $ json = [ 'type' => 'message/text' , 'text' => $ text , ] ; if ( ! empty ( $ suggestedActions ) ) { $ json [ 'suggestedActions' ] [ 'actions' ] = $ suggestedActions ; } return $ this -> request ( 'POST' , '/v3/conversations/' . $ target . '/ac...
Sends an activity message
16,871
protected function registerGaeConnector ( $ manager ) { $ app = $ this -> app ; $ manager -> addConnector ( 'gae' , function ( ) use ( $ app ) { return new GaeConnector ( $ app [ 'encrypter' ] , $ app [ 'request' ] ) ; } ) ; }
Register the GAE queue connector .
16,872
public function bootstrap ( ) { if ( ! $ this -> runningInConsole && $ this -> initializeFs ( ) ) { $ this -> buildFsTree ( ) ; $ this -> initialized = true ; } return $ this -> initialized ; }
Bootstraps the Optimizer .
16,873
public function getCachedConfigPath ( ) { if ( $ this -> initialized && env ( 'CACHE_CONFIG_FILE' ) ) { $ this -> cacheFile ( $ this -> basePath . '/bootstrap/cache/config.php' , $ this -> configPath ) ; return $ this -> configPath ; } return false ; }
Get the path to the configuration cache file .
16,874
public function getCachedRoutesPath ( ) { if ( $ this -> initialized && env ( 'CACHE_ROUTES_FILE' ) ) { $ this -> cacheFile ( $ this -> basePath . '/bootstrap/cache/routes.php' , $ this -> routesPath ) ; return $ this -> routesPath ; } return false ; }
Get the path to the routes cache file .
16,875
protected function cacheFile ( $ path , $ cachefsPath ) { if ( array_key_exists ( $ path , $ this -> cachedFiles ) ) { return ; } if ( file_exists ( $ path ) ) { $ contents = file_get_contents ( $ path ) ; file_put_contents ( $ cachefsPath , $ contents ) ; $ this -> cachedFiles [ $ path ] = $ cachefsPath ; } }
Adds the requested file to cache .
16,876
public static function initialize ( ) { if ( self :: $ registered ) { return true ; } try { if ( is_null ( self :: cache ( ) ) ) { return false ; } stream_wrapper_register ( self :: PROTOCOL , 'Shpasser\GaeSupportL5\Storage\CacheFs' ) ; self :: $ registered = true ; } catch ( \ RuntimeException $ ex ) { return false ; ...
Establishes a connection to memcached server and registers the Stream Wrapper .
16,877
private static function cache ( ) { if ( is_null ( self :: $ memcached ) && class_exists ( 'Memcached' ) ) { $ servers = [ [ 'host' => '127.0.0.1' , 'port' => 11211 , 'weight' => 100 ] ] ; self :: $ memcached = new Memcached ( ) ; foreach ( $ servers as $ server ) { self :: $ memcached -> addServer ( $ server [ 'host' ...
Returns the memcached instance .
16,878
public function rename ( $ from , $ to ) { $ contents = self :: cache ( ) -> get ( $ from ) ; if ( false === $ contents ) { return false ; } self :: cache ( ) -> delete ( $ from ) ; self :: cache ( ) -> set ( $ to , $ contents ) ; return true ; }
Renames a storage object .
16,879
public function stream_open ( $ path , $ mode , $ options , & $ opened_path ) { $ contents = self :: cache ( ) -> get ( $ path ) ; $ fileExists = ( false !== $ contents ) ; switch ( $ mode ) { case 'r' : case 'rb' : case 'r+' : case 'rb+' : if ( ! $ fileExists ) { return false ; } $ this -> fd = fopen ( 'php://memory' ...
Opens a stream .
16,880
public function url_stat ( $ path , $ flags ) { $ now = time ( ) ; $ stat = [ 'dev' => 0 , 'ino' => 0 , 'mode' => 0 , 'nlink' => 1 , 'uid' => 0 , 'gid' => 0 , 'rdev' => 0 , 'size' => 0 , 'atime' => $ now , 'mtime' => $ now , 'ctime' => $ now , 'blksize' => 512 , 'blocks' => 0 , ] ; if ( array_has ( self :: $ folders , ...
Returns stat information for a given path .
16,881
public function read ( $ file ) { $ this -> filePath = $ file ; $ this -> lines = file ( $ this -> filePath , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ; }
Reads a ENV file into an array .
16,882
public function write ( $ file = "" ) { $ envString = $ this -> generateEnvString ( $ this -> lines ) ; file_put_contents ( $ file ? $ file : $ this -> filePath , $ envString ) ; }
Writes the configuration data back to the ENV file .
16,883
protected function parseEnvLine ( $ line , & $ key , & $ value ) { $ parseOk = false ; $ keyExpr = '/(^\S+)\s*=\s*/' ; if ( preg_match ( $ keyExpr , $ line , $ matched ) === 1 ) { $ key = $ matched [ 1 ] ; $ value = substr ( $ line , strlen ( $ matched [ 0 ] ) ) ; $ parseOk = true ; } return $ parseOk ; }
Parses key and value for a given line .
16,884
protected function findLine ( $ key ) { $ parsedKey = null ; $ parsedValue = null ; foreach ( $ this -> lines as $ index => $ line ) { $ parseOk = $ this -> parseEnvLine ( $ line , $ parsedKey , $ parsedValue ) ; if ( $ parseOk && $ key === $ parsedKey ) { return $ index ; } } return - 1 ; }
Finds the line containing the given key .
16,885
public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { $ this -> lines [ ] = $ value ; } else { $ index = $ this -> findLine ( $ offset ) ; if ( $ index >= 0 ) { $ this -> lines [ $ index ] = "{$offset}={$value}" ; } else { $ this -> lines [ ] = "{$offset}={$value}" ; } } }
Assigns a value to the specified offset
16,886
public function offsetExists ( $ offset ) { $ lineFound = false ; $ index = $ this -> findLine ( $ offset ) ; if ( $ index >= 0 ) { $ lineFound = true ; } return $ lineFound ; }
Whether or not an offset exists
16,887
public function offsetUnset ( $ offset ) { $ index = $ this -> findLine ( $ offset ) ; if ( $ index >= 0 ) { unset ( $ this -> lines [ $ index ] ) ; } }
Un - sets an offset
16,888
protected function getAttachmentsArray ( $ message ) { $ attachments = array ( ) ; foreach ( $ message -> getChildren ( ) as $ entity ) { if ( $ entity instanceof Swift_Attachment ) { $ attachments [ ] = array ( 'name' => $ entity -> getFilename ( ) , 'data' => $ entity -> getBody ( ) , 'content_id' => "<{$entity->getC...
Returns an array of attachments extracted from a given mail message .
16,889
public function getCachedServicesPath ( ) { $ path = $ this -> optimizer -> getCachedServicesPath ( ) ; if ( $ path ) { return $ path ; } if ( $ this -> isRunningOnGae ( ) ) { return $ this -> storagePath ( ) . '/framework/services.json' ; } return parent :: getCachedServicesPath ( ) ; }
Get the path to the cached services . json file .
16,890
protected function replaceDefaultSymfonyLineDumpers ( ) { HtmlDumper :: $ defaultOutput = CliDumper :: $ defaultOutput = function ( $ line , $ depth , $ indentPad ) { if ( - 1 !== $ depth ) { echo str_repeat ( $ indentPad , $ depth ) . $ line . PHP_EOL ; } } ; }
Replaces the default output stream of Symfony s CliDumper and HtmlDumper classes in order to be able to run on Google App Engine .
16,891
public function storagePath ( ) { if ( $ this -> runningOnGae ) { if ( ! is_null ( $ this -> gaeBucketPath ) ) { return $ this -> gaeBucketPath ; } $ buckets = ini_get ( 'google_app_engine.allow_include_gs_buckets' ) ; $ bucket = current ( explode ( ', ' , $ buckets ) ) ; if ( $ bucket ) { $ this -> gaeBucketPath = "gs...
Override the storage path
16,892
public function onOpen ( ConnectionInterface $ connection ) { $ session_manager = new SessionManager ( $ connection ) ; $ session_manager -> resolveSession ( ) ; $ client = new Client ( $ connection , $ session_manager ) ; $ this -> clients -> add ( $ client ) ; $ this -> command -> info ( 'Client connected' ) ; Event ...
Client connected .
16,893
public function onMessage ( ConnectionInterface $ from , $ message ) { $ incoming_client = $ this -> clients -> findByConnection ( $ from ) ; if ( $ incoming_client ) { $ message = new Message ( $ message ) ; Event :: fire ( new MessageReceived ( $ this -> server , $ this -> clients , $ incoming_client , $ message ) ) ...
Incoming message .
16,894
public function onClose ( ConnectionInterface $ connection ) { $ client = $ this -> clients -> findByConnection ( $ connection ) ; if ( $ client ) { $ this -> clients -> remove ( $ client ) ; $ this -> command -> info ( 'Client disconnected' ) ; Event :: fire ( new ClientDisconnected ( $ this -> server , $ this -> clie...
Client disconnected .
16,895
public function onError ( ConnectionInterface $ connection , Exception $ e ) { $ this -> command -> error ( $ e -> getMessage ( ) ) ; \ Log :: error ( $ e ) ; $ connection -> close ( ) ; }
Socket error .
16,896
public function allOtherClients ( ) { $ current_client = $ this -> client ; $ filter = function ( $ client ) use ( $ current_client ) { return $ client !== $ current_client ; } ; return $ this -> clients -> filter ( $ filter ) ; }
Get all users connected .
16,897
public function exec ( $ command ) { $ command = implode ( ' ' , func_get_args ( ) ) ; fwrite ( $ this -> _fp , str_replace ( "\n" , '\n' , $ command ) . PHP_EOL ) ; $ answer = fgets ( $ this -> _fp ) ; if ( is_string ( $ answer ) ) { if ( substr ( $ answer , 0 , 7 ) === 'ANSWER ' ) { $ bytes = ( ( int ) substr ( $ ans...
Executes a command on the telegram - cli . Line - breaks will be escaped as telgram - cli does not support them .
16,898
private function getCookie ( $ name , $ decrypt = false ) { try { $ cookies = $ this -> connection -> WebSocket -> request -> getCookies ( ) ; if ( isset ( $ cookies [ $ name ] ) ) { $ raw = rawurldecode ( $ cookies [ $ name ] ) ; if ( ! $ decrypt ) { return $ raw ; } $ decrypted = @ Crypt :: decrypt ( $ raw ) ; if ( $...
Gets a cookie by the name and if needed can decrypt the value .
16,899
public function resolveSession ( ) { $ cookie_name = Config :: get ( 'session.cookie' ) ; $ session_id = $ this -> getCookie ( $ cookie_name , true ) ; if ( ! $ session_id ) { return null ; } $ this -> session -> setId ( $ session_id ) ; return $ this -> session ; }
Resolves the laravel session and sets the session .