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 ) { re...
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_BLOC...
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 ) ) ; $ ...
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_FINI...
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 UnrecoverableJobExcepti...
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 -> queu...
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 ( $ filte...
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 , ] ) ; $ responseDat...
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 -> ...
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 = $ resp...
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 , '_f...
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 ( '...
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...
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 ,...
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_...
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 , ] ) ; $ respon...
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 ...
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 = $ resp...
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 , ] ) ; $ resp...
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 = ...
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 ( $ ac...
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 ( ...
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 , sel...
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 , sel...
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 , ...
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 :...
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 -> cre...
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 (...
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 -> pro...
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...
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 g...
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 ) ; } ...
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 Instal...
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 ) { $ th...
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' ) ; $ filesToRemo...
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 ) ; }...
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 c...
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' => nul...
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' ] . '/' . $ projectNam...
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 ) ) { $...
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' ...
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 -> ou...
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 -> skipOrderin...
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 ) ...
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 ...
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 ( ...
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}...
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...
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' ) , ] ) ; i...
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 ( $ f...
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 $ proc...
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 .