idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
52,900
|
public static function getKey ( string $ value ) : string { self :: assertIsValidValue ( $ value ) ; return ( string ) array_search ( $ value , static :: toArray ( ) , true ) ; }
|
Return Enum Key for requested Value .
|
52,901
|
protected static function count ( $ blockSize = Cuid :: NORMAL_BLOCK ) { static $ count = 0 ; return Cuid :: pad ( base_convert ( ++ $ count , Cuid :: DECIMAL , Cuid :: BASE36 ) , $ blockSize ) ; }
|
Counter used to prevent same machine collision
|
52,902
|
protected static function fingerprint ( $ blockSize = Cuid :: NORMAL_BLOCK ) { $ pid = Cuid :: pad ( base_convert ( getmypid ( ) , Cuid :: DECIMAL , Cuid :: BASE36 ) , Cuid :: NORMAL_BLOCK / 2 ) ; $ hostname = Cuid :: pad ( base_convert ( array_reduce ( str_split ( gethostname ( ) ) , function ( $ carry , $ char ) { return $ carry + ord ( $ char ) ; } , strlen ( gethostname ( ) ) + Cuid :: BASE36 ) , Cuid :: DECIMAL , Cuid :: BASE36 ) , 2 ) ; if ( $ blockSize == Cuid :: SMALL_BLOCK ) { return substr ( $ pid , 0 , 1 ) . substr ( $ hostname , - 1 ) ; } return $ pid . $ hostname ; }
|
Fingerprint are used for process identification
|
52,903
|
protected static function pad ( $ input , $ size ) { $ input = str_pad ( $ input , Cuid :: BASE36 , '0' , STR_PAD_LEFT ) ; return substr ( $ input , strlen ( $ input ) - $ size ) ; }
|
Pad the input string into specific size
|
52,904
|
protected static function random ( $ blockSize = Cuid :: NORMAL_BLOCK ) { $ modifier = pow ( Cuid :: BASE36 , Cuid :: NORMAL_BLOCK ) ; $ random = mt_rand ( ) / mt_getrandmax ( ) ; $ random = $ random * $ modifier ; $ hash = Cuid :: pad ( base_convert ( $ random , Cuid :: DECIMAL , Cuid :: BASE36 ) , Cuid :: NORMAL_BLOCK ) ; if ( $ blockSize == Cuid :: SMALL_BLOCK ) { $ hash = substr ( $ hash , - 2 ) ; } return $ hash ; }
|
Generate random hash
|
52,905
|
protected static function timestamp ( $ blockSize = Cuid :: NORMAL_BLOCK ) { $ hash = base_convert ( floor ( microtime ( true ) * 1000 ) , Cuid :: DECIMAL , Cuid :: BASE36 ) ; if ( $ blockSize == Cuid :: SMALL_BLOCK ) { $ hash = substr ( $ hash , - 2 ) ; } return $ hash ; }
|
Generate timestamp based hash
|
52,906
|
public static function cuid ( ) { $ prefix = 'c' ; $ timestamp = Cuid :: timestamp ( ) ; $ count = Cuid :: count ( ) ; $ fingerprint = Cuid :: fingerprint ( ) ; $ random = Cuid :: random ( ) . Cuid :: random ( ) ; return $ prefix . $ timestamp . $ count . $ fingerprint . $ random ; }
|
Generate full version cuid
|
52,907
|
public static function slug ( ) { $ timestamp = Cuid :: timestamp ( Cuid :: SMALL_BLOCK ) ; $ count = Cuid :: count ( Cuid :: SMALL_BLOCK ) ; $ fingerprint = Cuid :: fingerprint ( Cuid :: SMALL_BLOCK ) ; $ random = Cuid :: random ( Cuid :: SMALL_BLOCK ) ; return $ timestamp . $ count . $ fingerprint . $ random ; }
|
Generate short version cuid
|
52,908
|
protected static function mintTime ( $ node = null ) { $ time = microtime ( 1 ) * 10000000 + static :: INTERVAL ; $ time = sprintf ( "%F" , $ time ) ; preg_match ( "/^\d+/" , $ time , $ time ) ; $ time = base_convert ( $ time [ 0 ] , 10 , 16 ) ; $ time = pack ( "H*" , str_pad ( $ time , 16 , "0" , STR_PAD_LEFT ) ) ; $ uuid = $ time [ 4 ] . $ time [ 5 ] . $ time [ 6 ] . $ time [ 7 ] . $ time [ 2 ] . $ time [ 3 ] . $ time [ 0 ] . $ time [ 1 ] ; $ uuid .= static :: randomBytes ( 2 ) ; $ uuid [ 8 ] = chr ( ord ( $ uuid [ 8 ] ) & static :: CLEAR_VAR | static :: VAR_RFC ) ; $ uuid [ 6 ] = chr ( ord ( $ uuid [ 6 ] ) & static :: CLEAR_VER | static :: VERSION_1 ) ; if ( ! is_null ( $ node ) ) { $ node = static :: makeBin ( $ node , 6 ) ; } if ( is_null ( $ node ) ) { $ node = static :: randomBytes ( 6 ) ; $ node [ 0 ] = pack ( "C" , ord ( $ node [ 0 ] ) | 1 ) ; } $ uuid .= $ node ; return $ uuid ; }
|
Generates a Version 1 UUID . These are derived from the time at which they were generated .
|
52,909
|
protected function finishJob ( Job $ job , bool $ internal ) : void { if ( $ this -> logger ) { $ this -> logger -> info ( 'Finished a job.' , [ 'name' => $ job -> getName ( ) , 'arguments' => $ job -> getArguments ( ) , ] ) ; } if ( $ this -> eventDispatcher ) { $ this -> eventDispatcher -> dispatch ( self :: JOB_FINISHED_EVENT , new FinishedJobEvent ( $ job , $ internal ) ) ; } if ( $ this -> triggerBatchEvents ) { $ this -> finishBatch ( new JobBatch ( [ ] , [ $ job ] ) ) ; } }
|
Called when a job is finished .
|
52,910
|
protected function failedJob ( Job $ job , \ Throwable $ exception , bool $ internal ) : void { if ( $ this -> logger ) { $ context = [ 'name' => $ job -> getName ( ) , 'arguments' => $ job -> getArguments ( ) , 'message' => $ exception -> getMessage ( ) , 'retryable' => ! $ exception instanceof UnrecoverableJobExceptionInterface , 'internal' => $ internal , ] ; if ( ( $ p = $ exception -> getPrevious ( ) ) ) { $ context [ 'cause' ] = $ p -> getMessage ( ) ; } $ this -> logger -> error ( 'Job failed.' , $ context ) ; } if ( $ this -> eventDispatcher ) { $ this -> eventDispatcher -> dispatch ( self :: JOB_FAILED_EVENT , new FailedJobEvent ( $ job , $ exception , $ internal ) ) ; } if ( $ this -> triggerBatchEvents ) { $ batch = new JobBatch ( [ $ job ] ) ; $ batch -> next ( ) ; $ batch -> result ( $ exception ) ; $ this -> finishBatch ( $ batch ) ; } }
|
Called when a job failed .
|
52,911
|
public function execute ( array $ arguments ) : void { if ( ! isset ( $ arguments [ 'job' ] ) ) { throw new UnrecoverableJobException ( 'Missing doctrine delay job' ) ; } $ job = $ arguments [ 'job' ] ; if ( ! $ job instanceof DoctrineDelayJob ) { throw new UnrecoverableJobException ( 'Invalid job' ) ; } $ this -> queueManagerRegistry -> put ( $ job -> getName ( ) , $ job -> getArguments ( ) , $ job -> getOptions ( ) , $ job -> getManager ( ) ) ; }
|
Called to start the queued task .
|
52,912
|
protected function executeJob ( Job $ job ) : ? \ Throwable { try { $ this -> jobExecutor -> executeJob ( $ job , $ this -> retryLimit ) ; } catch ( \ Throwable $ e ) { return $ e ; } return null ; }
|
Executes a single job .
|
52,913
|
public function generateNextJob ( ) : self { $ tokens = $ this -> getJobTokens ( ) ; $ tokens [ 'token' ] = $ tokens [ 'next_token' ] ; $ tokens [ 'next_token' ] = Uuid :: uuid4 ( ) -> toString ( ) ; return new self ( $ this -> getName ( ) , $ this -> getArguments ( ) , $ tokens ) ; }
|
Get the next run of this job .
|
52,914
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ filters = [ ] , array $ fields = [ ] ) : array { $ params = [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ; if ( ! empty ( $ filters ) ) { $ params [ 'query' ] = $ this -> buildQueryString ( $ filters ) ; } $ opportunities = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-opportunities' ) , $ params ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ opportunity ) { $ opportunities [ ] = new Opportunity ( $ opportunity ) ; } return $ opportunities ; }
|
Gets up to the specified number of opportunities that matches the given criteria .
|
52,915
|
public function delete ( Opportunity $ opportunity ) : void { $ id = $ opportunity -> getId ( ) ; $ opportunity -> setId ( null ) ; $ this -> client -> delete ( $ this -> prepareUrlForKey ( 'delete-opportunity' , [ 'id' => $ id ] ) ) ; }
|
Deletes the given opportunity .
|
52,916
|
public function getOpportunity ( $ opportunityId ) : Opportunity { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ opportunityId ) ; }
|
Gets the information about the opportunity that matches the given ID .
|
52,917
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ leadStatuses = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-statuses' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ leadStatus ) { $ leadStatuses [ ] = new LeadStatus ( $ leadStatus ) ; } return $ leadStatuses ; }
|
Gets up to the specified number of lead statuses that match the given criteria .
|
52,918
|
public function getStatus ( string $ leadStatusId ) : LeadStatus { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ leadStatusId ) ; }
|
Gets the information about the lead status that matches the given ID .
|
52,919
|
private function createHttpClientInstance ( HttpClientInterface $ httpClient ) : HttpClientInterface { return new PluginClient ( $ httpClient , [ new BaseUriPlugin ( $ this -> uriFactory -> createUri ( $ this -> configuration -> getBaseUrl ( ) ) ) , new AuthenticationPlugin ( new BasicAuth ( $ this -> configuration -> getApiKey ( ) , '' ) ) , new HeaderSetPlugin ( [ 'User-Agent' => self :: USER_AGENT , 'Content-Type' => 'application/json' , ] ) , ] ) ; }
|
Returns a new HTTP client that wraps the given one and configures it to use the base URL specified in the configuration and the access token for the Basic Auth .
|
52,920
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ tasks = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-tasks' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ task ) { $ tasks [ ] = new Task ( $ task ) ; } return $ tasks ; }
|
Gets up to the specified number of tasks that matches the given criteria .
|
52,921
|
public function getTask ( $ id ) : Task { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ id ) ; }
|
Gets the information about the task that matches the given ID .
|
52,922
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ filters = [ ] , array $ fields = [ ] ) : array { $ leads = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-leads' ) , array_merge ( $ filters , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ lead ) { $ leads [ ] = new Lead ( $ lead ) ; } return $ leads ; }
|
Gets up to the specified number of leads that matches the given criteria .
|
52,923
|
public function delete ( Lead $ lead ) : void { $ id = $ lead -> getId ( ) ; $ lead -> setId ( null ) ; $ this -> client -> delete ( $ this -> prepareUrlForKey ( 'delete-lead' , [ 'id' => $ id ] ) ) ; }
|
Deletes the given lead .
|
52,924
|
public function merge ( Lead $ source , Lead $ destination ) : void { if ( empty ( $ source -> getId ( ) ) || empty ( $ destination -> getId ( ) ) ) { throw new InvalidParamException ( 'You need to specify two already existing leads in order to merge them' ) ; } $ this -> client -> post ( $ this -> prepareUrlForKey ( 'merge-leads' ) , [ ] , [ 'destination' => $ destination -> getId ( ) , 'source' => $ source -> getId ( ) , ] ) ; }
|
Merges two leads .
|
52,925
|
public function findLeads ( array $ queryParams ) : array { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use list() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> list ( 0 , self :: MAX_ITEMS_PER_REQUEST , $ queryParams ) ; }
|
Get all the leads that match the given criteria .
|
52,926
|
public function getLead ( string $ id ) : Lead { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ id ) ; }
|
Gets the lead with the given ID .
|
52,927
|
public function hasError ( ) : bool { return isset ( $ this -> decodedBody [ 'error' ] ) || isset ( $ this -> decodedBody [ 'errors' ] ) || isset ( $ this -> decodedBody [ 'field-errors' ] ) ; }
|
Gets whether the Close . io server returned an error .
|
52,928
|
private function decodeBody ( ) : void { if ( empty ( $ this -> body ) || $ this -> body === null ) { $ this -> decodedBody = [ ] ; return ; } $ this -> decodedBody = json_decode ( $ this -> body , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new JsonException ( 'The body of the response could not be decoded as JSON.' ) ; } if ( ! \ is_array ( $ this -> decodedBody ) ) { $ this -> decodedBody = [ ] ; } }
|
Converts the raw response into an array .
|
52,929
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ filters = [ ] , array $ fields = [ ] ) : array { $ activities = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'list-sms' ) , array_merge ( $ filters , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ activity ) { $ activities [ ] = new SmsActivity ( $ activity ) ; } return $ activities ; }
|
Gets up to the specified number of SMS activities that match the given criteria .
|
52,930
|
protected function appendParamsToUrl ( string $ url , array $ params ) : string { if ( empty ( $ params [ '_fields' ] ) ) { unset ( $ params [ '_fields' ] ) ; } if ( empty ( $ params ) ) { return $ url ; } if ( isset ( $ params [ '_fields' ] ) && \ is_array ( $ params [ '_fields' ] ) ) { $ params [ '_fields' ] = array_unique ( array_merge ( $ params [ '_fields' ] , [ 'id' ] ) ) ; $ params [ '_fields' ] = implode ( ',' , $ params [ '_fields' ] ) ; } if ( strpos ( $ url , '?' ) === false ) { return $ url . '?' . http_build_query ( $ params , '' , '&' ) ; } list ( $ path , $ query ) = explode ( '?' , $ url , 2 ) ; parse_str ( $ query , $ existingParams ) ; $ params = array_merge ( $ params , $ existingParams ) ; return $ path . '?' . http_build_query ( $ params , '' , '&' ) ; }
|
Appends the given set of params to the URL .
|
52,931
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ customFields = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-custom-fields' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ customField ) { $ customFields [ ] = new CustomField ( $ customField ) ; } return $ customFields ; }
|
Gets up to the specified number of custom fields that match the given criteria .
|
52,932
|
public function create ( CustomField $ customField ) : CustomField { $ response = $ this -> client -> post ( $ this -> prepareUrlForKey ( 'create-custom-field' ) , [ ] , $ customField -> jsonSerialize ( ) ) ; $ responseData = $ response -> getDecodedBody ( ) ; return new CustomField ( $ responseData ) ; }
|
Creates a new custom field using the given information .
|
52,933
|
public function delete ( CustomField $ customField ) : void { $ id = $ customField -> getId ( ) ; $ customField -> setId ( null ) ; $ this -> client -> delete ( $ this -> prepareUrlForKey ( 'delete-custom-field' , [ 'id' => $ id ] ) ) ; }
|
Deletes the given custom field .
|
52,934
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ filters = [ ] , array $ fields = [ ] ) : array { $ activities = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-calls' ) , array_merge ( $ filters , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ) ; if ( $ response -> getHttpStatusCode ( ) === StatusCodeInterface :: STATUS_OK && ! $ response -> hasError ( ) ) { $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ activity ) { $ activities [ ] = new CallActivity ( $ activity ) ; } } return $ activities ; }
|
Gets up to the specified number of activities that match the given criteria .
|
52,935
|
public function get ( string $ id , array $ fields = [ ] ) : CallActivity { $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-call' , [ 'id' => $ id ] ) , [ '_fields' => $ fields ] ) ; return new CallActivity ( $ response -> getDecodedBody ( ) ) ; }
|
Gets the information about the call activity that matches the given ID .
|
52,936
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ users = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-users' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ user ) { $ users [ ] = new User ( $ user ) ; } return $ users ; }
|
Gets all the users who are members of the same organizations as the user currently making the request .
|
52,937
|
public function getCurrent ( array $ fields = [ ] ) : User { $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-current-user' ) , [ '_fields' => $ fields ] ) ; return new User ( $ response -> getDecodedBody ( ) ) ; }
|
Gets the information about the current logged - in user .
|
52,938
|
public function getUser ( string $ id ) : User { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ id ) ; }
|
Gets the information about the user that matches the given ID .
|
52,939
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ opportunityStatuses = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-statuses' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ opportunityStatus ) { $ opportunityStatuses [ ] = new OpportunityStatus ( $ opportunityStatus ) ; } return $ opportunityStatuses ; }
|
Gets up to the specified number of opportunity statuses that match the given criteria .
|
52,940
|
public function delete ( OpportunityStatus $ opportunityStatus ) : void { $ id = $ opportunityStatus -> getId ( ) ; $ opportunityStatus -> setId ( null ) ; $ this -> client -> delete ( $ this -> prepareUrlForKey ( 'delete-status' , [ 'id' => $ id ] ) ) ; }
|
Deletes the given opportunity status .
|
52,941
|
public function getStatus ( $ opportunityStatusId ) : OpportunityStatus { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ opportunityStatusId ) ; }
|
Gets the information about the opportunity status that matches the given ID .
|
52,942
|
public function list ( int $ offset = 0 , int $ limit = self :: MAX_ITEMS_PER_REQUEST , array $ fields = [ ] ) : array { $ contacts = [ ] ; $ response = $ this -> client -> get ( $ this -> prepareUrlForKey ( 'get-contacts' ) , [ '_skip' => $ offset , '_limit' => $ limit , '_fields' => $ fields , ] ) ; $ responseData = $ response -> getDecodedBody ( ) ; foreach ( $ responseData [ 'data' ] as $ contact ) { $ contacts [ ] = new Contact ( $ contact ) ; } return $ contacts ; }
|
Gets up to the specified number of contacts that matches the given criteria .
|
52,943
|
public function delete ( Contact $ contact ) : void { $ id = $ contact -> getId ( ) ; $ contact -> setId ( null ) ; $ this -> client -> delete ( $ this -> prepareUrlForKey ( 'delete-contact' , [ 'id' => $ id ] ) ) ; }
|
Deletes the given contact .
|
52,944
|
public function getContact ( $ contactId ) : Contact { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; return $ this -> get ( $ contactId ) ; }
|
Gets the information about the contact that matches the given ID .
|
52,945
|
public function addNote ( NoteActivity $ activity ) { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use NoteActivityApi::create() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getNoteActivitiesApi ( ) ; return $ apiHandler -> create ( $ activity ) ; }
|
Creates a new note activity using the given information .
|
52,946
|
public function addEmail ( EmailActivity $ activity ) { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use EmailActivityApi::create() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getEmailActivitiesApi ( ) ; return $ apiHandler -> create ( $ activity ) ; }
|
Creates a new email activity using the given information .
|
52,947
|
public function getNotes ( array $ filters ) : array { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use NoteActivityApi::list() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getNoteActivitiesApi ( ) ; return $ apiHandler -> list ( 0 , self :: MAX_ITEMS_PER_REQUEST , $ filters ) ; }
|
Gets the note activities that match the given criteria .
|
52,948
|
public function getCalls ( array $ filters ) : array { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use CallActivityApi::list() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getCallActivitiesApi ( ) ; return $ apiHandler -> list ( 0 , self :: MAX_ITEMS_PER_REQUEST , $ filters ) ; }
|
Gets the call activities that match the given criteria .
|
52,949
|
public function getEmails ( array $ filters ) : array { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use EmailActivityApi::list() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getEmailActivitiesApi ( ) ; return $ apiHandler -> list ( 0 , self :: MAX_ITEMS_PER_REQUEST , $ filters ) ; }
|
Gets the email activities that match the given criteria .
|
52,950
|
public function getSmss ( array $ filters ) : array { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use SmsActivityApi::list() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getSmsActivitiesApi ( ) ; return $ apiHandler -> list ( 0 , self :: MAX_ITEMS_PER_REQUEST , $ filters ) ; }
|
Gets the SMS activities that match the given criteria .
|
52,951
|
public function getSms ( string $ id ) : SmsActivity { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use SmsActivityApi::get() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getSmsActivitiesApi ( ) ; return $ apiHandler -> get ( $ id ) ; }
|
Gets the information about the SMS activity that matches the given ID .
|
52,952
|
public function addSms ( SmsActivity $ activity ) : SmsActivity { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 0.8. Use SmsActivityApi::create() instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ apiHandler = $ this -> closeIoApiWrapper -> getSmsActivitiesApi ( ) ; return $ apiHandler -> create ( $ activity ) ; }
|
Creates a new SMS activity using the given information .
|
52,953
|
public static function create ( CloseIoResponse $ response ) : self { switch ( $ response -> getHttpStatusCode ( ) ) { case StatusCodeInterface :: STATUS_UNAUTHORIZED : return new CloseIoAuthenticationException ( $ response ) ; case StatusCodeInterface :: STATUS_TOO_MANY_REQUESTS : return new CloseIoThrottleException ( $ response ) ; case StatusCodeInterface :: STATUS_NOT_FOUND : return new CloseIoResourceNotFoundException ( $ response ) ; case StatusCodeInterface :: STATUS_BAD_REQUEST : return new CloseIoBadRequestException ( $ response ) ; default : return new static ( $ response ) ; } }
|
A factory method for creating the appropriate exception based on the response from Close . io .
|
52,954
|
protected function checkProjectName ( ) { if ( is_dir ( $ this -> projectDir ) && ! $ this -> isEmptyDirectory ( $ this -> projectDir ) ) { throw new \ RuntimeException ( sprintf ( "There is already a '%s' project in this directory (%s).\n" . 'Change your project name or create it in another directory.' , $ this -> projectName , $ this -> projectDir ) ) ; } if ( 'demo' === $ this -> projectName && 'new' === $ this -> getName ( ) ) { $ this -> output -> writeln ( "\n <bg=yellow> TIP </> If you want to download the Symfony Demo app, execute 'symfony demo' instead of 'symfony new demo'" ) ; } return $ this ; }
|
Checks the project name .
|
52,955
|
protected function getInstalledSymfonyVersion ( ) { $ symfonyVersion = $ this -> composerManager -> getPackageVersion ( 'symfony/symfony' ) ; if ( ! empty ( $ symfonyVersion ) && 'v' === substr ( $ symfonyVersion , 0 , 1 ) ) { return substr ( $ symfonyVersion , 1 ) ; } return $ symfonyVersion ; }
|
Returns the full Symfony version number of the project by getting it from the composer . lock file .
|
52,956
|
protected function checkPermissions ( ) { $ projectParentDirectory = dirname ( $ this -> projectDir ) ; if ( ! is_writable ( $ projectParentDirectory ) ) { throw new IOException ( sprintf ( 'Installer does not have enough permissions to write to the "%s" directory.' , $ projectParentDirectory ) ) ; } return $ this ; }
|
Checks if the installer has enough permissions to create the project .
|
52,957
|
protected function getErrorMessage ( \ Requirement $ requirement , $ lineSize = 70 ) { if ( $ requirement -> isFulfilled ( ) ) { return ; } $ errorMessage = wordwrap ( $ requirement -> getTestMessage ( ) , $ lineSize - 3 , PHP_EOL . ' ' ) . PHP_EOL ; $ errorMessage .= ' > ' . wordwrap ( $ requirement -> getHelpText ( ) , $ lineSize - 5 , PHP_EOL . ' > ' ) . PHP_EOL ; return $ errorMessage ; }
|
Formats the error message contained in the given Requirement item using the optional line length provided .
|
52,958
|
protected function checkInstallerVersion ( ) { if ( 'phar://' !== substr ( __DIR__ , 0 , 7 ) ) { return $ this ; } if ( ! $ this -> isInstallerUpdated ( ) ) { $ this -> output -> writeln ( sprintf ( "\n <bg=red> WARNING </> Your Symfony Installer version (%s) is outdated.\n" . ' Execute the command "%s selfupdate" to get the latest version (%s).' , $ this -> localInstallerVersion , $ _SERVER [ 'PHP_SELF' ] , $ this -> latestInstallerVersion ) ) ; } return $ this ; }
|
Checks if the installed version is the latest one and displays some warning messages if not .
|
52,959
|
protected function getUrlContents ( $ url ) { $ client = $ this -> getGuzzleClient ( ) ; return $ client -> get ( $ url ) -> getBody ( ) -> getContents ( ) ; }
|
Returns the contents obtained by making a GET request to the given URL .
|
52,960
|
private function getExecutedCommand ( ) { $ pathDirs = explode ( PATH_SEPARATOR , $ _SERVER [ 'PATH' ] ) ; $ executedCommand = $ _SERVER [ 'PHP_SELF' ] ; $ executedCommandDir = dirname ( $ executedCommand ) ; if ( in_array ( $ executedCommandDir , $ pathDirs ) ) { $ executedCommand = basename ( $ executedCommand ) ; } return $ executedCommand ; }
|
Returns the executed command .
|
52,961
|
private function downloadNewVersion ( ) { if ( ! is_writable ( $ this -> currentInstallerFile ) ) { throw new IOException ( 'Symfony Installer update failed: the "' . $ this -> currentInstallerFile . '" file could not be written' ) ; } if ( ! is_writable ( $ this -> tempDir ) ) { throw new IOException ( 'Symfony Installer update failed: the "' . $ this -> tempDir . '" directory used to download files temporarily could not be written' ) ; } if ( false === $ newInstaller = $ this -> getUrlContents ( $ this -> remoteInstallerFile ) ) { throw new \ RuntimeException ( 'The new version of the Symfony Installer couldn\'t be downloaded from the server.' ) ; } $ newInstallerPermissions = $ this -> currentInstallerFile ? fileperms ( $ this -> currentInstallerFile ) : 0777 & ~ umask ( ) ; $ this -> fs -> dumpFile ( $ this -> newInstallerFile , $ newInstaller , $ newInstallerPermissions ) ; return $ this ; }
|
Downloads the new version of the Symfony installer .
|
52,962
|
private function backupCurrentVersion ( ) { $ this -> fs -> copy ( $ this -> currentInstallerFile , $ this -> currentInstallerBackupFile , true ) ; $ this -> restorePreviousInstaller = true ; return $ this ; }
|
Does a backup of the current version of the Symfony installer .
|
52,963
|
private function replaceCurrentVersionbyNewVersion ( ) { $ this -> fs -> copy ( $ this -> newInstallerFile , $ this -> currentInstallerFile , true ) ; return $ this ; }
|
Replaces the currenct version of the Symfony installer with the new one .
|
52,964
|
private function rollback ( ) { $ this -> output -> writeln ( array ( '' , '<error>There was an error while updating the installer.</error>' , 'The previous Symfony Installer version has been restored.' , '' , ) ) ; $ this -> fs -> remove ( $ this -> newInstallerFile ) ; if ( $ this -> restorePreviousInstaller ) { $ this -> fs -> copy ( $ this -> currentInstallerBackupFile , $ this -> currentInstallerFile , true ) ; } }
|
Restores the previously installed version of the Symfony installer .
|
52,965
|
protected function cleanUp ( ) { $ this -> fs -> remove ( dirname ( $ this -> downloadedFilePath ) ) ; try { $ licenseFile = array ( $ this -> projectDir . '/LICENSE' ) ; $ upgradeFiles = glob ( $ this -> projectDir . '/UPGRADE*.md' ) ; $ changelogFiles = glob ( $ this -> projectDir . '/CHANGELOG*.md' ) ; $ filesToRemove = array_merge ( $ licenseFile , $ upgradeFiles , $ changelogFiles ) ; $ this -> fs -> remove ( $ filesToRemove ) ; } catch ( \ Exception $ e ) { } return $ this ; }
|
Removes all the temporary files and directories created to download the project and removes Symfony - related files that don t make sense in a proprietary project .
|
52,966
|
protected function dumpReadmeFile ( ) { $ readmeContents = sprintf ( "%s\n%s\n\nA Symfony project created on %s.\n" , $ this -> projectName , str_repeat ( '=' , strlen ( $ this -> projectName ) ) , date ( 'F j, Y, g:i a' ) ) ; try { $ this -> fs -> dumpFile ( $ this -> projectDir . '/README.md' , $ readmeContents ) ; } catch ( \ Exception $ e ) { } return $ this ; }
|
Dump a basic README . md file .
|
52,967
|
protected function updateParameters ( ) { $ filename = $ this -> projectDir . '/app/config/parameters.yml' ; if ( ! is_writable ( $ filename ) ) { if ( $ this -> output -> isVerbose ( ) ) { $ this -> output -> writeln ( sprintf ( " <comment>[WARNING]</comment> The value of the <info>secret</info> configuration option cannot be updated because\n" . " the <comment>%s</comment> file is not writable.\n" , $ filename ) ) ; } return $ this ; } $ ret = str_replace ( 'ThisTokenIsNotSoSecretChangeIt' , $ this -> generateRandomSecret ( ) , file_get_contents ( $ filename ) ) ; file_put_contents ( $ filename , $ ret ) ; return $ this ; }
|
Updates the Symfony parameters . yml file to replace default configuration values with better generated values .
|
52,968
|
protected function updateComposerConfig ( ) { parent :: updateComposerConfig ( ) ; $ this -> composerManager -> updateProjectConfig ( array ( 'name' => $ this -> composerManager -> createPackageName ( $ this -> projectName ) , 'license' => 'proprietary' , 'description' => null , 'extra' => array ( 'branch-alias' => null ) , ) ) ; return $ this ; }
|
Updates the composer . json file to provide better values for some of the default configuration values .
|
52,969
|
public function createPackageName ( $ projectName ) { if ( ! empty ( $ _SERVER [ 'USERNAME' ] ) ) { $ packageName = $ _SERVER [ 'USERNAME' ] . '/' . $ projectName ; } elseif ( true === extension_loaded ( 'posix' ) && $ user = posix_getpwuid ( posix_getuid ( ) ) ) { $ packageName = $ user [ 'name' ] . '/' . $ projectName ; } elseif ( get_current_user ( ) ) { $ packageName = get_current_user ( ) . '/' . $ projectName ; } else { $ packageName = $ projectName . '/' . $ projectName ; } return $ this -> fixPackageName ( $ packageName ) ; }
|
Generates a good Composer project name based on the application name and on the user name .
|
52,970
|
private function getProjectConfig ( ) { $ composerJsonPath = $ this -> projectDir . '/composer.json' ; if ( ! is_writable ( $ composerJsonPath ) ) { return [ ] ; } return json_decode ( file_get_contents ( $ composerJsonPath ) , true ) ; }
|
It returns the project s Composer config as a PHP array .
|
52,971
|
private function saveProjectConfig ( array $ config ) { $ composerJsonPath = $ this -> projectDir . '/composer.json' ; $ this -> fs -> dumpFile ( $ composerJsonPath , json_encode ( $ config , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . "\n" ) ; $ this -> syncComposerLockFile ( ) ; }
|
It saves the given PHP array as the project s Composer config . In addition to JSON - serializing the contents it synchronizes the composer . lock file to avoid out - of - sync Composer errors .
|
52,972
|
private function syncComposerLockFile ( ) { $ composerJsonFileContents = file_get_contents ( $ this -> projectDir . '/composer.json' ) ; $ composerLockFileContents = json_decode ( file_get_contents ( $ this -> projectDir . '/composer.lock' ) , true ) ; if ( array_key_exists ( 'hash' , $ composerLockFileContents ) ) { $ composerLockFileContents [ 'hash' ] = md5 ( $ composerJsonFileContents ) ; } if ( array_key_exists ( 'content-hash' , $ composerLockFileContents ) ) { $ composerLockFileContents [ 'content-hash' ] = $ this -> getComposerContentHash ( $ composerJsonFileContents ) ; } $ this -> fs -> dumpFile ( $ this -> projectDir . '/composer.lock' , json_encode ( $ composerLockFileContents , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . "\n" ) ; }
|
Updates the hash values stored in composer . lock to avoid out - of - sync problems when the composer . json file contents are changed .
|
52,973
|
private function getComposerContentHash ( $ composerJsonFileContents ) { $ composerConfig = json_decode ( $ composerJsonFileContents , true ) ; $ relevantKeys = array ( 'name' , 'version' , 'require' , 'require-dev' , 'conflict' , 'replace' , 'provide' , 'minimum-stability' , 'prefer-stable' , 'repositories' , 'extra' , ) ; $ relevantComposerConfig = array ( ) ; foreach ( array_intersect ( $ relevantKeys , array_keys ( $ composerConfig ) ) as $ key ) { $ relevantComposerConfig [ $ key ] = $ composerConfig [ $ key ] ; } if ( isset ( $ composerConfig [ 'config' ] [ 'platform' ] ) ) { $ relevantComposerConfig [ 'config' ] [ 'platform' ] = $ composerConfig [ 'config' ] [ 'platform' ] ; } ksort ( $ relevantComposerConfig ) ; return md5 ( json_encode ( $ relevantComposerConfig ) ) ; }
|
Returns the md5 hash of the sorted content of the composer file .
|
52,974
|
private function displayInstallationResult ( ) { if ( empty ( $ this -> requirementsErrors ) ) { $ this -> output -> writeln ( sprintf ( " <info>%s</info> Symfony Demo Application was <info>successfully installed</info>. Now you can:\n" , defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ? 'OK' : '✔' ) ) ; } else { $ this -> output -> writeln ( sprintf ( " <comment>%s</comment> Symfony Demo Application was <info>successfully installed</info> but your system doesn't meet the\n" . " technical requirements to run Symfony applications! Fix the following issues before executing it:\n" , defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ? 'FAILED' : '✕' ) ) ; foreach ( $ this -> requirementsErrors as $ helpText ) { $ this -> output -> writeln ( ' * ' . $ helpText ) ; } $ this -> output -> writeln ( sprintf ( " After fixing these issues, re-check Symfony requirements executing this command:\n\n" . " <comment>php %s/bin/symfony_requirements</comment>\n\n" . " Then, you can:\n" , $ this -> projectName ) ) ; } $ serverRunCommand = extension_loaded ( 'pcntl' ) ? 'server:start' : 'server:run' ; $ this -> output -> writeln ( sprintf ( " 1. Change your current directory to <comment>%s</comment>\n\n" . " 2. Execute the <comment>php bin/console %s</comment> command to run the demo application.\n\n" . " 3. Browse to the <comment>http://localhost:8000</comment> URL to see the demo application in action.\n\n" , $ this -> projectDir , $ serverRunCommand ) ) ; $ this -> output -> writeln ( "<bg=yellow> WARNING </>\n\n" . " This installer downloads the old Symfony Demo version based on Symfony 3.\n" . " If you prefer to install the new version based on Symfony 4 and Symfony Flex,\n" . " execute the following command:\n\n" . " composer create-project symfony/symfony-demo\n" ) ; return $ this ; }
|
It displays the message with the result of installing the Symfony Demo application and provides some pointers to the user .
|
52,975
|
public function flushCache ( ) { if ( $ this -> eventFlushCache === false || config ( 'repositories.cache_enabled' , false ) === false ) { return false ; } $ tag = get_called_class ( ) ; return self :: getCacheInstance ( ) -> tags ( [ 'repositories' , $ tag ] ) -> flush ( ) ; }
|
Flush the cache for the given repository .
|
52,976
|
protected function getCacheExpiresTime ( $ time = null ) { if ( $ time === self :: EXPIRES_END_OF_DAY ) { return class_exists ( Carbon :: class ) ? round ( Carbon :: now ( ) -> secondsUntilEndOfDay ( ) / 60 ) : $ this -> cacheMinutes ; } return $ time ? : $ this -> cacheMinutes ; }
|
Return the time until expires in minutes .
|
52,977
|
public function newQuery ( $ skipOrdering = false ) { $ this -> query = $ this -> getNew ( ) -> newQuery ( ) ; if ( $ skipOrdering === false && $ this -> skipOrderingOnce === false ) { foreach ( $ this -> getOrderBy ( ) as $ column => $ dir ) { $ this -> query -> orderBy ( $ column , $ dir ) ; } } $ this -> skipOrderingOnce = false ; $ this -> applyScope ( ) ; return $ this ; }
|
Get a new query builder instance with the applied the order by and scopes .
|
52,978
|
public function find ( $ id , $ columns = [ '*' ] ) { $ this -> newQuery ( ) ; return $ this -> query -> find ( $ id , $ columns ) ; }
|
Find data by its primary key .
|
52,979
|
public function findAllBy ( $ attribute , $ value , $ columns = [ '*' ] ) { $ this -> newQuery ( ) ; if ( is_array ( $ value ) ) { return $ this -> query -> whereIn ( $ attribute , $ value ) -> get ( $ columns ) ; } return $ this -> query -> where ( $ attribute , '=' , $ value ) -> get ( $ columns ) ; }
|
Find data by field
|
52,980
|
public function orderBy ( $ column , $ direction ) { if ( in_array ( $ column , $ this -> orderable ) === false && array_key_exists ( $ column , $ this -> orderable ) === false ) { return $ this ; } $ this -> skipOrderingOnce = true ; return $ this -> addScopeQuery ( function ( $ query ) use ( $ column , $ direction ) { $ direction = in_array ( strtolower ( $ direction ) , [ 'desc' , 'asc' ] ) ? $ direction : 'asc' ; $ column = Arr :: get ( $ this -> orderable , $ column , $ column ) ; return $ query -> orderBy ( $ this -> appendTableName ( $ column ) , $ direction ) ; } ) ; }
|
Order results by .
|
52,981
|
public function getSearchableKeys ( ) { return array_values ( array_map ( function ( $ value , $ key ) { return ( is_array ( $ value ) || is_numeric ( $ key ) === false ) ? $ key : $ value ; } , $ this -> searchable , array_keys ( $ this -> searchable ) ) ) ; }
|
Return searchable keys .
|
52,982
|
public function search ( $ queries ) { if ( is_string ( $ queries ) ) { $ queries = [ 'query' => $ queries , ] ; } return $ this -> addScopeQuery ( function ( $ query ) use ( $ queries ) { $ joined = [ ] ; foreach ( $ this -> searchable as $ param => $ columns ) { $ param = is_numeric ( $ param ) ? $ columns : $ param ; $ value = Arr :: get ( $ queries , $ param , '' ) ; if ( $ value === '' || $ value === null ) continue ; $ columns = ( array ) $ columns ; foreach ( $ columns as $ key => $ column ) { @ list ( $ joining_table , $ options ) = explode ( ':' , $ column ) ; if ( $ options !== null ) { @ list ( $ column , $ foreign_key , $ related_key , $ alias ) = explode ( ',' , $ options ) ; if ( isset ( $ joined [ $ joining_table ] ) == false ) { $ joined [ $ joining_table ] = $ this -> addSearchJoin ( $ query , $ joining_table , $ foreign_key , $ related_key ? : $ param , $ alias ) ; } $ columns [ $ key ] = "{$joined[$joining_table]}.{$column}" ; } } if ( $ this -> createSearchRangeClause ( $ query , $ value , $ columns ) ) { continue ; } if ( count ( $ columns ) > 1 ) { $ query -> where ( function ( $ q ) use ( $ columns , $ param , $ value ) { foreach ( $ columns as $ column ) { $ this -> createSearchClause ( $ q , $ param , $ column , $ value , 'or' ) ; } } ) ; } else { $ this -> createSearchClause ( $ query , $ param , $ columns [ 0 ] , $ value ) ; } } $ query -> addSelect ( [ $ this -> getModel ( ) -> getTable ( ) . '.*' , ] ) ; return $ query ; } ) ; }
|
Filter results by given query params .
|
52,983
|
public function update ( Model $ entity , array $ attributes ) { if ( $ entity -> update ( $ attributes ) ) { $ this -> flushCache ( ) ; return true ; } return false ; }
|
Update an entity with the given attributes and persist it
|
52,984
|
public function delete ( $ entity ) { if ( ( $ entity instanceof Model ) === false ) { $ entity = $ this -> find ( $ entity ) ; } if ( $ entity -> delete ( ) ) { $ this -> flushCache ( ) ; return true ; } return false ; }
|
Delete a entity in repository
|
52,985
|
protected function appendTableName ( $ column ) { if ( strpos ( $ column , '.' ) === false ) { return $ this -> modelInstance -> getTable ( ) . '.' . $ column ; } if ( substr ( $ column , 0 , 2 ) === '_.' ) { return preg_replace ( '/^_\./' , '' , $ column ) ; } return $ column ; }
|
Append table name to column .
|
52,986
|
protected function createSearchClause ( Builder $ query , $ param , $ column , $ value , $ boolean = 'and' ) { if ( $ param === 'query' ) { $ query -> where ( $ this -> appendTableName ( $ column ) , self :: $ searchOperator , '%' . $ value . '%' , $ boolean ) ; } elseif ( is_array ( $ value ) ) { $ query -> whereIn ( $ this -> appendTableName ( $ column ) , $ value , $ boolean ) ; } else { $ query -> where ( $ this -> appendTableName ( $ column ) , '=' , $ value , $ boolean ) ; } }
|
Add a search where clause to the query .
|
52,987
|
protected function addSearchJoin ( Builder $ query , $ joining_table , $ foreign_key , $ related_key , $ alias ) { $ local_table = $ this -> getModel ( ) -> getTable ( ) ; $ table = $ alias ? "{$joining_table} as {$alias}" : $ joining_table ; $ alias = $ alias ? : $ joining_table ; $ query -> join ( $ table , "{$alias}.{$foreign_key}" , "{$local_table}.{$related_key}" ) ; return $ alias ; }
|
Add a search join to the query .
|
52,988
|
protected function createSearchRangeClause ( Builder $ query , $ value , array $ columns ) { if ( is_array ( $ value ) === true ) { return false ; } $ range_type = strtolower ( substr ( $ value , 0 , 2 ) ) ; if ( substr ( $ value , 2 , 1 ) === ':' && in_array ( $ range_type , $ this -> range_keys ) ) { $ value = substr ( $ value , 3 ) ; switch ( $ range_type ) { case 'gt' : $ query -> where ( $ this -> appendTableName ( $ columns [ 0 ] ) , '>' , $ value , 'and' ) ; break ; case 'lt' : $ query -> where ( $ this -> appendTableName ( $ columns [ 0 ] ) , '<' , $ value , 'and' ) ; break ; case 'ne' : $ query -> where ( $ this -> appendTableName ( $ columns [ 0 ] ) , '<>' , $ value , 'and' ) ; break ; case 'bt' : if ( count ( $ values = explode ( ',' , $ value ) ) === 2 ) { $ query -> whereBetween ( $ this -> appendTableName ( $ columns [ 0 ] ) , $ values ) ; } break ; } return true ; } return false ; }
|
Add a range clause to the query .
|
52,989
|
public function generateTokenById ( $ id ) { if ( ! is_null ( $ user = $ this -> provider -> retrieveById ( $ id ) ) ) { return $ this -> jwt -> fromUser ( $ user ) ; } }
|
Generate new token by ID .
|
52,990
|
public function match ( array $ methods , string $ pattern , $ handler ) { $ this [ 'route.collector' ] -> addRoute ( $ methods , $ pattern , $ handler ) ; }
|
Maps various HTTP requests to handler .
|
52,991
|
public function publish ( $ module ) { with ( new MigrationPublisher ( $ module ) ) -> setRepository ( $ this -> laravel [ 'modules' ] ) -> setConsole ( $ this ) -> publish ( ) ; }
|
Publish migration for the specified module .
|
52,992
|
protected function migrate ( $ name ) { $ module = $ this -> module -> findOrFail ( $ name ) ; $ this -> call ( 'migrate' , [ '--path' => $ this -> getPath ( $ module ) , '--database' => $ this -> option ( 'database' ) , '--pretend' => $ this -> option ( 'pretend' ) , '--force' => $ this -> option ( 'force' ) , ] ) ; if ( $ this -> option ( 'seed' ) ) { $ this -> call ( 'module:seed' , [ 'module' => $ name ] ) ; } }
|
Run the migration from the specified module .
|
52,993
|
public function getMigrations ( $ reverse = false ) { $ files = $ this -> laravel [ 'files' ] -> glob ( $ this -> getPath ( ) . '/*_*.php' ) ; if ( $ files === false ) { return array ( ) ; } $ files = array_map ( function ( $ file ) { return str_replace ( '.php' , '' , basename ( $ file ) ) ; } , $ files ) ; sort ( $ files ) ; if ( $ reverse ) { return array_reverse ( $ files ) ; } return $ files ; }
|
Get migration files .
|
52,994
|
public function getByStatus ( $ status ) { $ modules = [ ] ; foreach ( $ this -> all ( ) as $ name => $ module ) { if ( $ module -> isStatus ( $ status ) ) { $ modules [ $ name ] = $ module ; } } return $ modules ; }
|
Get modules by status .
|
52,995
|
public function getProcess ( ) { switch ( $ this -> type ) { case 'github' : case 'github-https' : case 'bitbucket' : if ( $ this -> tree ) { $ process = $ this -> installViaSubtree ( ) ; } $ process = $ this -> installViaGit ( ) ; break ; default : $ process = $ this -> installViaComposer ( ) ; break ; } return $ process ; }
|
Get process instance .
|
52,996
|
public function installViaGit ( ) { return new Process ( sprintf ( 'cd %s && git clone %s %s && cd %s && git checkout %s' , base_path ( ) , $ this -> getRepoUrl ( ) , $ this -> getDestinationPath ( ) , $ this -> getDestinationPath ( ) , $ this -> getBranch ( ) ) ) ; }
|
Install the module via git .
|
52,997
|
protected function registerAliases ( ) { $ loader = AliasLoader :: getInstance ( ) ; foreach ( $ this -> get ( 'aliases' , [ ] ) as $ aliasName => $ aliasClass ) { $ loader -> alias ( $ aliasName , $ aliasClass ) ; } }
|
Register the aliases from this module .
|
52,998
|
public function disable ( ) { $ this -> app [ 'events' ] -> fire ( 'module.disabling' , [ $ this ] ) ; $ this -> setActive ( 0 ) ; $ this -> app [ 'events' ] -> fire ( 'module.disabled' , [ $ this ] ) ; }
|
Disable the current module .
|
52,999
|
public function stringify ( $ data ) { return array_map ( function ( $ item ) { return is_array ( $ item ) ? json_encode ( $ item , JSON_OBJECT_AS_ARRAY ) : ( string ) $ item ; } , $ data ) ; }
|
Convert all items to string .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.