idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
51,200
private function promptLegacyMigrate ( ) { static $ asked = false ; $ localProject = $ this -> getService ( 'local.project' ) ; if ( $ localProject -> getLegacyProjectRoot ( ) && $ this -> getName ( ) !== 'legacy-migrate' && ! $ asked ) { $ asked = true ; $ projectRoot = $ this -> getProjectRoot ( ) ; $ timestamp = tim...
Prompt the user to migrate from the legacy project file structure .
51,201
protected function checkUpdates ( ) { if ( self :: $ checkedUpdates ) { return ; } self :: $ checkedUpdates = true ; if ( ! extension_loaded ( 'Phar' ) ) { return ; } $ pharFilename = \ Phar :: running ( false ) ; if ( ! $ pharFilename ) { return ; } if ( ! is_writable ( $ pharFilename ) ) { return ; } $ config = $ thi...
Check for updates .
51,202
public function getCurrentProject ( ) { if ( isset ( $ this -> currentProject ) ) { return $ this -> currentProject ; } if ( ! $ projectRoot = $ this -> getProjectRoot ( ) ) { return false ; } $ project = false ; $ localProject = $ this -> getService ( 'local.project' ) ; $ config = $ localProject -> getProjectConfig (...
Get the current project if the user is in a project directory .
51,203
public function getCurrentEnvironment ( Project $ expectedProject = null , $ refresh = null ) { if ( ! ( $ projectRoot = $ this -> getProjectRoot ( ) ) || ! ( $ project = $ this -> getCurrentProject ( ) ) || ( $ expectedProject !== null && $ expectedProject -> id !== $ project -> id ) ) { return false ; } $ git = $ thi...
Get the current environment if the user is in a project directory .
51,204
public function updateDrushAliases ( EnvironmentsChangedEvent $ event ) { $ projectRoot = $ this -> getProjectRoot ( ) ; if ( ! $ projectRoot ) { return ; } if ( ! $ this -> getApplication ( ) -> has ( 'local:drush-aliases' ) ) { return ; } try { $ currentProject = $ this -> getCurrentProject ( ) ; if ( ! $ currentProj...
Update the user s local Drush aliases .
51,205
protected function shouldWait ( InputInterface $ input ) { if ( $ input -> hasOption ( 'no-wait' ) && $ input -> getOption ( 'no-wait' ) ) { return false ; } if ( $ input -> hasOption ( 'wait' ) && $ input -> getOption ( 'wait' ) ) { return true ; } if ( $ this -> detectRunningInHook ( ) ) { $ serviceName = $ this -> c...
Returns whether we should wait for an operation to complete .
51,206
protected function detectRunningInHook ( ) { $ envPrefix = $ this -> config ( ) -> get ( 'service.env_prefix' ) ; if ( getenv ( $ envPrefix . 'PROJECT' ) && basename ( getenv ( 'SHELL' ) ) === 'dash' && ! $ this -> isTerminal ( STDIN ) ) { return true ; } return false ; }
Detects a Platform . sh non - terminal Dash environment ; i . e . a hook .
51,207
protected function selectProject ( $ projectId = null , $ host = null ) { if ( ! empty ( $ projectId ) ) { $ this -> project = $ this -> api ( ) -> getProject ( $ projectId , $ host ) ; if ( ! $ this -> project ) { throw new ConsoleInvalidArgumentException ( $ this -> getProjectNotFoundMessage ( $ projectId ) ) ; } $ t...
Select the project for the user based on input or the environment .
51,208
private function getProjectNotFoundMessage ( $ projectId ) { $ message = 'Specified project not found: ' . $ projectId ; if ( $ projects = $ this -> api ( ) -> getProjects ( ) ) { $ message .= "\n\nYour projects are:" ; $ limit = 8 ; foreach ( array_slice ( $ projects , 0 , $ limit ) as $ project ) { $ message .= "\n ...
Format an error message about a not - found project .
51,209
protected function selectEnvironment ( $ environmentId = null , $ required = true , $ selectDefaultEnv = false ) { $ envPrefix = $ this -> config ( ) -> get ( 'service.env_prefix' ) ; if ( $ environmentId === null && getenv ( $ envPrefix . 'BRANCH' ) ) { $ environmentId = getenv ( $ envPrefix . 'BRANCH' ) ; $ this -> s...
Select the current environment for the user .
51,210
protected function selectApp ( InputInterface $ input ) { $ appName = $ input -> getOption ( 'app' ) ; if ( $ appName ) { return $ appName ; } try { $ apps = array_map ( function ( WebApp $ app ) { return $ app -> name ; } , $ this -> api ( ) -> getCurrentDeployment ( $ this -> getSelectedEnvironment ( ) ) -> webapps )...
Find the name of the app the user wants to use for an SSH command .
51,211
protected final function offerProjectChoice ( array $ projects , $ text = 'Enter a number to choose a project:' ) { if ( ! isset ( $ this -> input ) || ! isset ( $ this -> output ) || ! $ this -> input -> isInteractive ( ) ) { throw new \ BadMethodCallException ( 'Not interactive: a project choice cannot be offered.' )...
Offer the user an interactive choice of projects .
51,212
protected final function offerEnvironmentChoice ( array $ environments ) { if ( ! isset ( $ this -> input ) || ! isset ( $ this -> output ) || ! $ this -> input -> isInteractive ( ) ) { throw new \ BadMethodCallException ( 'Not interactive: an environment choice cannot be offered.' ) ; } $ questionHelper = $ this -> ge...
Offers a choice of environments .
51,213
protected function runOtherCommand ( $ name , array $ arguments = [ ] , OutputInterface $ output = null ) { $ application = $ this -> getApplication ( ) ; $ command = $ application -> find ( $ name ) ; if ( isset ( $ this -> input ) ) { $ arguments += [ '--yes' => $ this -> input -> getOption ( 'yes' ) , '--no' => $ th...
Run another CLI command .
51,214
protected function setHiddenAliases ( array $ hiddenAliases ) { $ this -> hiddenAliases = $ hiddenAliases ; $ this -> setAliases ( array_merge ( $ this -> getAliases ( ) , $ hiddenAliases ) ) ; return $ this ; }
Add aliases that should be hidden from help .
51,215
private function labeledMessage ( $ label , $ message , $ options = 0 ) { if ( isset ( $ this -> stdErr ) ) { $ this -> stdErr -> writeln ( '<options=reverse>' . strtoupper ( $ label ) . '</> ' . $ message , $ options ) ; } }
Print a message with a label .
51,216
protected function buildDomainRows ( array $ tree ) { $ rows = [ ] ; $ formatter = $ this -> getService ( 'property_formatter' ) ; foreach ( $ tree as $ domain ) { $ rows [ ] = [ 'name' => $ domain -> id , 'ssl' => $ formatter -> format ( ( bool ) $ domain [ 'ssl' ] [ 'has_certificate' ] ) , 'created_at' => $ formatter...
Recursively build rows of the domain table .
51,217
protected function getAvailablePlans ( ) { $ config = $ this -> config ( ) ; if ( $ config -> has ( 'experimental.available_plans' ) ) { return $ config -> get ( 'experimental.available_plans' ) ; } return $ config -> get ( 'service.available_plans' ) ; }
Return a list of plans .
51,218
protected function getAvailableRegions ( $ runtime = false ) { if ( $ runtime ) { $ regions = [ ] ; foreach ( $ this -> api ( ) -> getClient ( ) -> getRegions ( ) as $ region ) { if ( $ region -> available ) { $ regions [ $ region -> id ] = $ region -> label ; } } } else { $ regions = ( array ) $ this -> config ( ) -> ...
Return a list of regions .
51,219
protected function getFields ( ) { return [ 'title' => new Field ( 'Project title' , [ 'optionName' => 'title' , 'description' => 'The initial project title' , 'questionLine' => '' , 'default' => 'Untitled Project' , ] ) , 'region' => new OptionsField ( 'Region' , [ 'optionName' => 'region' , 'description' => 'The regi...
Returns a list of ConsoleForm form fields for this command .
51,220
private function getTimeOption ( InputInterface $ input , $ optionName , $ min = 0 , $ max = 3600 ) { $ value = $ input -> getOption ( $ optionName ) ; if ( $ value <= $ min ) { $ value = $ min ; } elseif ( $ value > $ max ) { $ value = $ max ; } return $ value ; }
Get a numeric option value while ensuring it s a reasonable number .
51,221
public function waitAndLog ( Activity $ activity , $ success = null , $ failure = null ) { $ stdErr = $ this -> getStdErr ( ) ; $ stdErr -> writeln ( sprintf ( 'Waiting for the activity <info>%s</info> (%s):' , $ activity -> id , self :: getFormattedDescription ( $ activity ) ) ) ; $ bar = $ this -> newProgressBar ( $ ...
Wait for a single activity to complete and display the log continuously .
51,222
public static function formatState ( $ state ) { return isset ( self :: $ stateNames [ $ state ] ) ? self :: $ stateNames [ $ state ] : $ state ; }
Format a state name .
51,223
public static function formatResult ( $ result , $ decorate = true ) { $ name = isset ( self :: $ stateNames [ $ result ] ) ? self :: $ stateNames [ $ result ] : $ result ; return $ decorate && $ result === Activity :: RESULT_FAILURE ? '<error>' . $ name . '</error>' : $ name ; }
Format a result .
51,224
protected function newProgressBar ( OutputInterface $ output ) { $ progressOutput = $ output -> isDecorated ( ) ? $ output : new NullOutput ( ) ; return new ProgressBar ( $ progressOutput ) ; }
Initialize a new progress bar .
51,225
public static function getFormattedDescription ( Activity $ activity , $ withDecoration = true ) { if ( ! $ withDecoration ) { return $ activity -> getDescription ( false ) ; } $ value = $ activity -> getDescription ( true ) ; $ value = preg_replace ( '@<[^/][^>]+>@' , '<options=underscore>' , $ value ) ; $ value = pre...
Get the formatted description of an activity .
51,226
protected function processSpecialDestinations ( ) { foreach ( $ this -> specialDestinations as $ sourcePattern => $ relDestination ) { $ matched = glob ( $ this -> appRoot . '/' . $ sourcePattern , GLOB_NOSORT ) ; if ( ! $ matched ) { continue ; } if ( $ relDestination === '{webroot}' && $ this -> buildInPlace ) { cont...
Process the defined special destinations .
51,227
protected function getSharedDir ( ) { $ shared = $ this -> app -> getSourceDir ( ) . '/' . $ this -> config -> get ( 'local.shared_dir' ) ; if ( ! $ this -> app -> isSingle ( ) ) { $ shared .= '/' . preg_replace ( '/[^a-z0-9\-_]+/i' , '-' , $ this -> app -> getName ( ) ) ; } $ this -> fsHelper -> mkdir ( $ shared ) ; r...
Get the directory containing files shared between builds .
51,228
protected function copyToBuildDir ( ) { $ this -> buildInPlace = true ; $ buildDir = $ this -> buildDir ; if ( $ this -> app -> shouldMoveToRoot ( ) ) { $ buildDir .= '/' . $ this -> documentRoot ; } if ( ! empty ( $ this -> settings [ 'clone' ] ) ) { $ this -> cloneToBuildDir ( $ buildDir ) ; } elseif ( $ this -> copy...
Copy or symlink files from the app root to the build directory .
51,229
private function cloneToBuildDir ( $ buildDir ) { $ gitRoot = $ this -> gitHelper -> getRoot ( $ this -> appRoot , true ) ; $ ref = $ this -> gitHelper -> execute ( [ 'rev-parse' , 'HEAD' ] , $ gitRoot , true ) ; $ cloneArgs = [ '--recursive' , '--shared' ] ; $ tmpRepo = $ buildDir . '-repo' ; if ( file_exists ( $ tmpR...
Clone the app to the build directory via Git .
51,230
protected function processSharedFileMounts ( ) { $ sharedDir = $ this -> getSharedDir ( ) ; if ( $ sharedDir === false ) { return ; } if ( is_link ( $ this -> buildDir ) ) { return ; } $ sharedFileMounts = $ this -> app -> getSharedFileMounts ( ) ; if ( empty ( $ sharedFileMounts ) ) { return ; } $ sharedDirRelative = ...
Process shared file mounts in the application .
51,231
protected function installDrupalSettingsLocal ( ) { $ sitesDefault = $ this -> getWebRoot ( ) . '/sites/default' ; $ shared = $ this -> getSharedDir ( ) ; $ settingsLocal = $ sitesDefault . '/settings.local.php' ; if ( $ shared !== false && is_dir ( $ sitesDefault ) && ! file_exists ( $ settingsLocal ) ) { $ sharedSett...
Create a settings . local . php for a Drupal site .
51,232
protected function copyGitIgnore ( $ source ) { $ source = CLI_ROOT . '/resources/' . $ source ; $ gitRoot = $ this -> gitHelper -> getRoot ( $ this -> appRoot ) ; if ( ! $ gitRoot ) { return ; } $ appGitIgnore = $ this -> appRoot . '/.gitignore' ; if ( ! file_exists ( $ appGitIgnore ) && ! file_exists ( $ gitRoot . '/...
Create a default . gitignore file for the app .
51,233
public static function getTimezone ( ) { $ currentTz = @ date_default_timezone_get ( ) ; if ( $ currentTz !== 'UTC' ) { return $ currentTz ; } if ( ini_get ( 'date.timezone' ) ) { return ini_get ( 'date.timezone' ) ; } if ( getenv ( 'TZ' ) ) { return ( string ) getenv ( 'TZ' ) ; } if ( $ systemTz = self :: detectSystem...
Get the timezone intended by the user .
51,234
private static function detectSystemTimezone ( ) { if ( is_link ( '/etc/localtime' ) ) { $ filename = readlink ( '/etc/localtime' ) ; $ prefixes = [ '/usr/share/zoneinfo/' , '/var/db/timezone/zoneinfo/' , ] ; foreach ( $ prefixes as $ prefix ) { if ( strpos ( $ filename , $ prefix ) === 0 ) { return substr ( $ filename...
Detect the system timezone restoring functionality from PHP < 5 . 4 .
51,235
protected function handleApiException ( ClientException $ e , Project $ project ) { $ response = $ e -> getResponse ( ) ; if ( $ response !== null && $ response -> getStatusCode ( ) === 403 ) { $ project -> ensureFull ( ) ; $ data = $ project -> getData ( ) ; if ( ! $ project -> hasLink ( '#manage-domains' ) && ! empty...
Output a clear explanation for domains API errors .
51,236
public function getSiteAliasDir ( ) { $ aliasDir = $ this -> getDrushDir ( ) . '/site-aliases' ; if ( ! file_exists ( $ aliasDir ) && $ this -> getLegacyAliasFiles ( ) ) { $ aliasDir = $ this -> getDrushDir ( ) ; } return $ aliasDir ; }
Find the directory where global Drush site aliases should be stored .
51,237
public function getVersion ( $ reset = false ) { if ( $ reset || ! isset ( $ this -> version ) ) { $ this -> version = $ this -> shellHelper -> execute ( [ $ this -> getDrushExecutable ( ) , 'version' , '--format=string' ] ) ; } return $ this -> version ; }
Get the installed Drush version .
51,238
public function execute ( array $ args , $ dir = null , $ mustRun = false , $ quiet = true ) { array_unshift ( $ args , $ this -> getDrushExecutable ( ) ) ; return $ this -> shellHelper -> execute ( $ args , $ dir , $ mustRun , $ quiet ) ; }
Execute a Drush command .
51,239
protected function getDrushExecutable ( ) { if ( isset ( $ this -> executable ) ) { return $ this -> executable ; } if ( $ this -> config -> has ( 'local.drush_executable' ) ) { return $ this -> executable = $ this -> config -> get ( 'local.drush_executable' ) ; } $ projectRoot = $ this -> localProject -> getProjectRoo...
Get the full path to the Drush executable .
51,240
public function getAliases ( $ groupName , $ reset = false ) { if ( ! $ reset && isset ( $ this -> aliases [ $ groupName ] ) ) { return $ this -> aliases [ $ groupName ] ; } $ args = [ $ this -> getDrushExecutable ( ) , '@none' , 'sa' , '--format=json' , '@' . $ groupName ] ; $ aliases = [ ] ; try { $ result = $ this -...
Get existing Drush aliases for a group .
51,241
public function getAliasGroup ( Project $ project , $ projectRoot ) { $ config = $ this -> localProject -> getProjectConfig ( $ projectRoot ) ; return ! empty ( $ config [ 'alias-group' ] ) ? $ config [ 'alias-group' ] : $ project [ 'id' ] ; }
Get the alias group for a project .
51,242
public function createAliases ( Project $ project , $ projectRoot , $ environments , $ original = null ) { if ( ! $ apps = $ this -> getDrupalApps ( $ projectRoot ) ) { return false ; } $ group = $ this -> getAliasGroup ( $ project , $ projectRoot ) ; $ success = true ; foreach ( $ this -> getSiteAliasTypes ( ) as $ ty...
Create Drush aliases for the provided project and environments .
51,243
public function getDrupalApps ( $ projectRoot ) { return array_filter ( LocalApplication :: getApplications ( $ projectRoot , $ this -> config ) , function ( LocalApplication $ app ) { return Drupal :: isDrupal ( $ app -> getRoot ( ) ) ; } ) ; }
Find Drupal applications in a project .
51,244
protected function filterProjects ( array & $ projects , array $ filters ) { foreach ( $ filters as $ filter => $ value ) { switch ( $ filter ) { case 'host' : $ projects = array_filter ( $ projects , function ( Project $ project ) use ( $ value ) { return $ value === parse_url ( $ project -> getUri ( ) , PHP_URL_HOST ...
Filter the list of projects .
51,245
public function format ( array $ data , $ appendLineBreak = true ) { return implode ( $ this -> lineBreak , array_map ( [ $ this , 'formatRow' ] , $ data ) ) . ( $ appendLineBreak ? $ this -> lineBreak : '' ) ; }
Format an array of rows as a CSV spreadsheet .
51,246
private function formatCell ( $ cell ) { $ cell = ( string ) $ cell ; if ( strpbrk ( $ cell , '"' . $ this -> lineBreak . $ this -> delimiter ) !== false ) { $ cell = '"' . str_replace ( '"' , '""' , $ cell ) . '"' ; } $ cell = preg_replace ( '/\R/u' , $ this -> lineBreak , $ cell ) ; return $ cell ; }
Format a CSV cell .
51,247
private function getActivities ( InputInterface $ input , $ limit = 0 ) { if ( $ this -> hasSelectedEnvironment ( ) && ! $ input -> getOption ( 'all' ) ) { return $ this -> getSelectedEnvironment ( ) -> getActivities ( $ limit , $ input -> getOption ( 'type' ) ) ; } return $ this -> getSelectedProject ( ) -> getActivit...
Get activities on the project or environment .
51,248
private function getDuration ( Activity $ activity , $ now = null ) { if ( $ activity -> isComplete ( ) ) { $ end = strtotime ( $ activity -> completed_at ) ; } elseif ( ! empty ( $ activity -> started_at ) ) { $ now = $ now === null ? time ( ) : $ now ; $ end = $ now ; } else { $ end = strtotime ( $ activity -> update...
Calculates the duration of an activity whether complete or not .
51,249
protected function isServerRunningForApp ( $ appId , $ projectRoot ) { foreach ( $ this -> getServerInfo ( ) as $ address => $ server ) { if ( $ server [ 'appId' ] === $ appId && $ server [ 'projectRoot' ] === $ projectRoot ) { if ( $ this -> isProcessDead ( $ server [ 'pid' ] ) ) { $ this -> stopServer ( $ address ) ;...
Check whether another server is running for an app .
51,250
protected function isServerRunningForAddress ( $ address ) { $ pidFile = $ this -> getPidFile ( $ address ) ; $ serverInfo = $ this -> getServerInfo ( ) ; if ( file_exists ( $ pidFile ) ) { $ pid = file_get_contents ( $ pidFile ) ; } elseif ( isset ( $ serverInfo [ $ address ] ) ) { $ pid = $ serverInfo [ $ address ] [...
Check whether another server is running at an address .
51,251
protected function getServerInfo ( $ running = true ) { if ( ! isset ( $ this -> serverInfo ) ) { $ this -> serverInfo = [ ] ; $ filename = $ this -> config ( ) -> getWritableUserDir ( ) . '/local-servers.json' ; if ( file_exists ( $ filename ) ) { $ this -> serverInfo = ( array ) json_decode ( file_get_contents ( $ fi...
Get info on currently running servers .
51,252
protected function stopServer ( $ address , $ pid = null ) { $ success = true ; if ( $ pid && function_exists ( 'posix_kill' ) ) { $ success = posix_kill ( $ pid , SIGTERM ) ; if ( ! $ success ) { $ this -> stdErr -> writeln ( sprintf ( 'Failed to kill process <error>%d</error> (POSIX error %s)' , $ pid , posix_get_las...
Stop a running server .
51,253
protected function getPort ( $ default = 3000 ) { $ ports = [ ] ; foreach ( $ this -> getServerInfo ( ) as $ address => $ server ) { $ ports [ ] = $ server [ 'port' ] ; } return PortUtil :: getPort ( $ ports ? max ( $ ports ) + 1 : $ default ) ; }
Automatically determine the best port for a new server .
51,254
protected function createServerProcess ( $ address , $ docRoot , $ projectRoot , array $ appConfig , array $ env = [ ] ) { if ( isset ( $ appConfig [ 'type' ] ) ) { $ type = explode ( ':' , $ appConfig [ 'type' ] , 2 ) ; $ version = isset ( $ type [ 1 ] ) ? $ type [ 1 ] : false ; if ( $ type [ 0 ] === 'php' && $ versio...
Creates a process to start a web server .
51,255
protected function getServerPhpConfig ( ) { $ phpConfig = [ ] ; $ variables_order = ini_get ( 'variables_order' ) ; if ( strpos ( $ variables_order , 'E' ) === false ) { $ phpConfig [ 'variables_order' ] = 'E' . $ variables_order ; } return $ phpConfig ; }
Get custom PHP configuration for the built - in web server .
51,256
protected function createRouter ( $ projectRoot ) { static $ created = [ ] ; $ router_src = CLI_ROOT . '/resources/router/router.php' ; if ( ! file_exists ( $ router_src ) ) { throw new \ RuntimeException ( sprintf ( 'Router not found: <error>%s</error>' , $ router_src ) ) ; } $ router = $ projectRoot . '/' . $ this ->...
Create a router file .
51,257
protected function createEnv ( $ projectRoot , $ docRoot , $ address , array $ appConfig ) { $ realDocRoot = realpath ( $ docRoot ) ; $ envPrefix = $ this -> config ( ) -> get ( 'service.env_prefix' ) ; $ env = [ '_PLATFORM_VARIABLES_PREFIX' => $ envPrefix , $ envPrefix . 'ENVIRONMENT' => '_local' , $ envPrefix . 'APPL...
Create the virtual environment variables for a local server .
51,258
public function set ( $ key , $ value , $ save = true ) { $ this -> load ( ) ; NestedArrayUtil :: setNestedArrayValue ( $ this -> state , explode ( '.' , $ key ) , $ value ) ; if ( $ save ) { $ this -> save ( ) ; } }
Set a state value .
51,259
protected function load ( ) { if ( ! $ this -> loaded ) { $ filename = $ this -> getFilename ( ) ; if ( file_exists ( $ filename ) ) { $ content = file_get_contents ( $ filename ) ; $ this -> state = json_decode ( $ content , true ) ? : [ ] ; } $ this -> loaded = true ; } }
Load state .
51,260
private function validateEmail ( $ value ) { if ( empty ( $ value ) ) { throw new InvalidArgumentException ( 'An email address is required.' ) ; } if ( ! $ filtered = filter_var ( $ value , FILTER_VALIDATE_EMAIL ) ) { throw new InvalidArgumentException ( 'Invalid email address: ' . $ value ) ; } return $ filtered ; }
Validate an email address .
51,261
private function matchRole ( $ input , array $ roles ) { foreach ( $ roles as $ role ) { if ( strpos ( $ role , strtolower ( $ input ) ) === 0 ) { return $ role ; } } throw new InvalidArgumentException ( 'Invalid role: ' . $ input ) ; }
Complete a role name based on an array of allowed roles .
51,262
private function describeRoles ( array $ roles ) { $ withInitials = array_map ( function ( $ role ) { return sprintf ( '%s (%s)' , $ role , substr ( $ role , 0 , 1 ) ) ; } , $ roles ) ; $ last = array_pop ( $ withInitials ) ; return implode ( ' or ' , [ implode ( ', ' , $ withInitials ) , $ last ] ) ; }
Expand roles into a list with abbreviations .
51,263
private function getUserLabel ( ProjectAccess $ access ) { $ account = $ this -> api ( ) -> getAccount ( $ access ) ; return sprintf ( '<info>%s</info> (%s)' , $ account [ 'display_name' ] , $ account [ 'email' ] ) ; }
Return a label describing a user .
51,264
private function showProjectRoleForm ( $ defaultRole , InputInterface $ input ) { $ questionHelper = $ this -> getService ( 'question_helper' ) ; $ this -> stdErr -> writeln ( "The user's project role can be " . $ this -> describeRoles ( ProjectAccess :: $ roles ) . '.' ) ; $ this -> stdErr -> writeln ( '' ) ; $ questi...
Show the form for entering the project role .
51,265
private function getEnvironmentRoles ( ProjectAccess $ projectAccess ) { $ environmentRoles = [ ] ; if ( $ projectAccess -> role === ProjectAccess :: ROLE_ADMIN ) { return [ ] ; } $ progress = new ProgressBar ( isset ( $ this -> stdErr ) && $ this -> stdErr -> isDecorated ( ) ? $ this -> stdErr : new NullOutput ( ) ) ;...
Load the user s roles on the project s environments .
51,266
private function showEnvironmentRolesForm ( array $ defaultEnvironmentRoles , InputInterface $ input ) { $ questionHelper = $ this -> getService ( 'question_helper' ) ; $ desiredEnvironmentRoles = [ ] ; $ validEnvironmentRoles = array_merge ( EnvironmentAccess :: $ roles , [ 'none' ] ) ; $ this -> stdErr -> writeln ( "...
Show the form for entering environment roles .
51,267
private function loadCommitList ( Environment $ environment , Commit $ startCommit , $ limit = 10 ) { $ commits = [ $ startCommit ] ; if ( ! count ( $ startCommit -> parents ) || $ limit === 1 ) { return $ commits ; } $ gitData = $ this -> getService ( 'git_data_api' ) ; $ progress = new ProgressBar ( $ this -> stdErr ...
Load parent commits recursively up to the limit .
51,268
private function summarize ( $ message ) { $ message = ltrim ( $ message , "\n" ) ; if ( $ newLinePos = strpos ( $ message , "\n" ) ) { $ message = substr ( $ message , 0 , $ newLinePos ) ; } return rtrim ( $ message ) ; }
Summarize a commit message .
51,269
private function loadFromFile ( SessionInterface $ session ) { $ id = preg_replace ( '/[^\w\-]+/' , '-' , $ session -> getId ( ) ) ; $ dir = ( new Config ( ) ) -> getSessionDir ( ) ; $ filename = "$dir/sess-$id/sess-$id.json" ; if ( is_readable ( $ filename ) && ( $ contents = file_get_contents ( $ filename ) ) ) { $ d...
Load the session from an old file for backwards compatibility .
51,270
private function getKeyIdentifiers ( SessionInterface $ session ) { return [ '-a' . $ this -> getAccountName ( ) , '-s' . 'session-' . $ session -> getId ( ) , '-l' . $ this -> appName . ': ' . $ session -> getId ( ) , ] ; }
Get arguments identifying the key to the security utility .
51,271
private function deserialize ( $ data ) { $ result = json_decode ( base64_decode ( $ data , true ) , true ) ; return is_array ( $ result ) ? $ result : [ ] ; }
Deserialize session data .
51,272
protected function mergeExisting ( $ new , $ existing ) { foreach ( $ new as $ aliasName => & $ newAlias ) { if ( isset ( $ existing [ $ aliasName ] ) ) { $ newAlias = array_replace_recursive ( $ existing [ $ aliasName ] , $ newAlias ) ; } } return $ new ; }
Merge new aliases with existing ones .
51,273
protected function getExistingAliases ( $ currentGroup , $ previousGroup = null ) { $ aliases = [ ] ; foreach ( array_filter ( [ $ currentGroup , $ previousGroup ] ) as $ groupName ) { foreach ( $ this -> drush -> getAliases ( $ groupName ) as $ name => $ alias ) { $ name = ltrim ( $ name , '@' ) ; if ( strpos ( $ name...
Find the existing defined aliases so they can be merged with new ones .
51,274
protected function generateNewAliases ( array $ apps , array $ environments ) { $ aliases = [ ] ; foreach ( $ apps as $ app ) { $ appId = $ app -> getId ( ) ; $ localAliasName = '_local' ; if ( count ( $ apps ) > 1 ) { $ localAliasName .= '--' . $ appId ; } $ aliases [ $ localAliasName ] = $ this -> generateLocalAlias ...
Generate new aliases .
51,275
protected function generateRemoteAlias ( Environment $ environment , LocalApplication $ app ) { if ( ! $ environment -> hasLink ( 'ssh' ) ) { return false ; } $ sshUrl = $ environment -> getSshUrl ( $ app -> getName ( ) ) ; $ alias = [ 'options' => [ $ this -> getAutoRemoveKey ( ) => true , ] , ] ; if ( $ environment -...
Generate a remote Drush alias .
51,276
private function getUrl ( Environment $ environment ) { $ urls = $ environment -> getRouteUrls ( ) ; usort ( $ urls , function ( $ a , $ b ) { $ result = 0 ; foreach ( [ $ a , $ b ] as $ key => $ url ) { if ( parse_url ( $ url , PHP_URL_SCHEME ) === 'https' ) { $ result += $ key === 0 ? - 2 : 2 ; } } $ result += strlen...
Find a single URL for an environment .
51,277
protected function swapKeys ( array $ aliases , array $ map ) { return array_map ( function ( $ alias ) use ( $ map ) { foreach ( $ map as $ from => $ to ) { if ( isset ( $ alias [ $ from ] ) ) { $ alias [ $ to ] = $ alias [ $ from ] ; unset ( $ alias [ $ from ] ) ; } } return $ alias ; } , $ aliases ) ; }
Swap the key names in an array of aliases .
51,278
protected function getVersion ( ) { static $ version ; if ( ! $ version ) { $ version = false ; $ string = $ this -> execute ( [ '--version' ] , false ) ; if ( $ string && preg_match ( '/(^| )([0-9]+[^ ]*)/' , $ string , $ matches ) ) { $ version = $ matches [ 2 ] ; } } return $ version ; }
Get the installed version of the Git CLI .
51,279
public function getCurrentBranch ( $ dir = null , $ mustRun = false ) { $ args = [ 'symbolic-ref' , '--short' , 'HEAD' ] ; return $ this -> execute ( $ args , $ dir , $ mustRun ) ; }
Get the current branch name .
51,280
public function getMergedBranches ( $ ref = 'HEAD' , $ remote = false , $ dir = null , $ mustRun = false ) { $ args = [ 'branch' , '--list' , '--no-column' , '--no-color' , '--merged' , $ ref ] ; if ( $ remote ) { $ args [ ] = '--remote' ; } $ mergedBranches = $ this -> execute ( $ args , $ dir , $ mustRun ) ; $ array ...
Get a list of branches merged with a specific ref .
51,281
public function execute ( array $ args , $ dir = null , $ mustRun = false , $ quiet = true , array $ env = [ ] ) { if ( $ dir !== false ) { $ dir = $ dir ? : $ this -> repositoryDir ; } array_unshift ( $ args , 'git' ) ; return $ this -> shellHelper -> execute ( $ args , $ dir , $ mustRun , $ quiet , $ env + $ this -> ...
Execute a Git command .
51,282
public function init ( $ dir , $ mustRun = false ) { if ( is_dir ( $ dir . '/.git' ) ) { throw new \ InvalidArgumentException ( "Already a repository: $dir" ) ; } return ( bool ) $ this -> execute ( [ 'init' ] , $ dir , $ mustRun , false ) ; }
Create a Git repository in a directory .
51,283
public function remoteRefExists ( $ url , $ ref = null , $ heads = true ) { $ args = [ 'ls-remote' , $ url ] ; if ( $ heads ) { $ args [ ] = '--heads' ; } if ( $ ref !== null ) { $ args [ ] = $ ref ; } $ result = $ this -> execute ( $ args , false , true ) ; return ! is_bool ( $ result ) && strlen ( $ result ) > 0 ; }
Check whether a remote repository exists .
51,284
public function branchExists ( $ branchName , $ dir = null , $ mustRun = false ) { $ result = $ this -> execute ( [ 'branch' , '--list' , '--no-color' , '--no-column' ] , $ dir , $ mustRun ) ; $ branches = array_map ( function ( $ line ) { return trim ( ltrim ( $ line , '* ' ) ) ; } , explode ( "\n" , $ result ) ) ; re...
Check whether a branch exists .
51,285
public function remoteBranchExists ( $ remote , $ branchName , $ dir = null , $ mustRun = false ) { $ args = [ 'ls-remote' , $ remote , $ branchName ] ; $ result = $ this -> execute ( $ args , $ dir , $ mustRun ) ; return is_string ( $ result ) && strlen ( trim ( $ result ) ) ; }
Check whether a branch exists on a remote .
51,286
public function checkOutNew ( $ name , $ parent = null , $ upstream = null , $ dir = null , $ mustRun = false ) { $ args = [ 'checkout' , '-b' , $ name ] ; if ( $ parent !== null ) { $ args [ ] = $ parent ; } elseif ( $ upstream !== null ) { $ args [ ] = '--track' ; $ args [ ] = $ upstream ; } return ( bool ) $ this ->...
Create a new branch and check it out .
51,287
public function fetch ( $ remote , $ branch = null , $ dir = null , $ mustRun = false ) { $ args = [ 'fetch' , $ remote ] ; if ( $ branch !== null ) { $ args [ ] = $ branch ; } return ( bool ) $ this -> execute ( $ args , $ dir , $ mustRun , false ) ; }
Fetch from the Git remote .
51,288
public function checkOut ( $ name , $ dir = null , $ mustRun = false , $ quiet = false ) { return ( bool ) $ this -> execute ( [ 'checkout' , $ name , ] , $ dir , $ mustRun , $ quiet ) ; }
Check out a branch .
51,289
public function getUpstream ( $ branch = null , $ dir = null , $ mustRun = false ) { if ( $ branch === null ) { $ args = [ 'rev-parse' , '--abbrev-ref' , '--symbolic-full-name' , '@{u}' ] ; return $ this -> execute ( $ args , $ dir , $ mustRun ) ; } $ remoteName = $ this -> getConfig ( "branch.$branch.remote" , $ dir ,...
Get the upstream for a branch .
51,290
public function setUpstream ( $ upstream , $ branch = null , $ dir = null , $ mustRun = false ) { $ args = [ 'branch' ] ; if ( $ upstream !== false ) { $ args [ ] = '--set-upstream-to=' . $ upstream ; } else { $ args [ ] = '--unset-upstream' ; } if ( $ branch !== null ) { $ args [ ] = $ branch ; } return ( bool ) $ thi...
Set the upstream for the current branch .
51,291
public function getConfig ( $ key , $ dir = null , $ mustRun = false ) { $ args = [ 'config' , '--get' , $ key ] ; return $ this -> execute ( $ args , $ dir , $ mustRun ) ; }
Read a configuration item .
51,292
public function setSshCommand ( $ sshCommand ) { if ( empty ( $ sshCommand ) || $ sshCommand === 'ssh' ) { unset ( $ this -> env [ 'GIT_SSH_COMMAND' ] , $ this -> env [ 'GIT_SSH' ] ) ; } elseif ( ! $ this -> supportsGitSshCommand ( ) ) { $ this -> env [ 'GIT_SSH' ] = $ this -> writeSshFile ( $ sshCommand . " \$*\n" ) ;...
Set the SSH command for Git to use .
51,293
public function writeSshFile ( $ sshCommand ) { $ tempDir = sys_get_temp_dir ( ) ; $ tempFile = tempnam ( $ tempDir , 'cli-git-ssh' ) ; if ( ! $ tempFile ) { throw new \ RuntimeException ( 'Failed to create temporary file in: ' . $ tempDir ) ; } if ( ! file_put_contents ( $ tempFile , trim ( $ sshCommand ) . "\n" ) ) {...
Write an SSH command to a temporary file to be used with GIT_SSH .
51,294
public function validateUsernameOrEmail ( $ username ) { $ username = trim ( $ username ) ; if ( ! strlen ( $ username ) || ( ! filter_var ( $ username , FILTER_VALIDATE_EMAIL ) && ! $ this -> validateUsername ( $ username ) ) ) { throw new \ RuntimeException ( 'Please enter a valid email address or username.' ) ; } re...
Validation callback for the username or email address .
51,295
private function getServiceUrl ( array $ service ) { $ map = [ 'username' => 'user' , 'password' => 'pass' ] ; $ urlParts = [ ] ; foreach ( $ service as $ key => $ value ) { $ newKey = isset ( $ map [ $ key ] ) ? $ map [ $ key ] : $ key ; $ urlParts [ $ newKey ] = $ value ; } return Url :: buildUrl ( $ urlParts ) ; }
Build a URL to a service .
51,296
private function valuesAreEqual ( $ a , $ b ) { if ( is_array ( $ a ) && is_array ( $ b ) ) { ksort ( $ a ) ; ksort ( $ b ) ; } return $ a === $ b ; }
Compare new and old integration values .
51,297
public function setRelativeLinks ( $ relative = true ) { if ( OsUtil :: isWindows ( ) ) { $ relative = false ; } $ this -> relative = $ relative ; }
Set whether to use relative links .
51,298
protected function unprotect ( $ files , $ recursive = false ) { if ( ! $ files instanceof \ Traversable ) { $ files = new \ ArrayObject ( is_array ( $ files ) ? $ files : array ( $ files ) ) ; } foreach ( $ files as $ file ) { if ( is_link ( $ file ) ) { continue ; } elseif ( is_dir ( $ file ) ) { if ( ( ! is_executab...
Make files writable by the current user .
51,299
public function copy ( $ source , $ destination , $ override = false ) { if ( is_dir ( $ destination ) && ! is_dir ( $ source ) ) { $ destination = rtrim ( $ destination , '/' ) . '/' . basename ( $ source ) ; } $ this -> fs -> copy ( $ source , $ destination , $ override ) ; }
Copy a file if it is newer than the destination .