idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
57,400
public function query ( $ query , $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= $ this -> resourceRepo -> get ( 'query' ) ; $ url .= '?q=' ; $ url .= urlencode ( $ query ) ; $ queryResults = $ this -> request ( $ url , $ options ) ; return $ queryResults ; }
Executes a specified SOQL query .
57,401
public function next ( $ nextUrl , $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= $ nextUrl ; $ queryResults = $ this -> request ( $ url , $ options ) ; return $ queryResults ; }
Calls next query .
57,402
public function search ( $ query , $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= $ this -> resourceRepo -> get ( 'search' ) ; $ url .= '?q=' ; $ url .= urlencode ( $ query ) ; $ searchResults = $ this -> request ( $ url , $ options ) ; return $ searchResults ; }
Executes the specified SOSL query .
57,403
public function scopeOrder ( $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= $ this -> resourceRepo -> get ( 'search' ) ; $ url .= '/scopeOrder' ; $ scopeOrder = $ this -> request ( $ url , $ options ) ; return $ scopeOrder ; }
Returns an ordered list of objects in the default global search scope of a logged - in user . Global search keeps track of which objects the user interacts with and how often and arranges the search results accordingly . Objects used most frequently appear at the top of the list .
57,404
public function searchLayouts ( $ objectList , $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= $ this -> resourceRepo -> get ( 'search' ) ; $ url .= '/layout/?q=' ; $ url .= urlencode ( $ objectList ) ; $ searchLayouts = $ this -> request ( $ url , $ options ) ; return $ searchLayouts ; }
Returns search result layout information for the objects in the query string .
57,405
public function custom ( $ customURI , $ options = [ ] ) { $ url = $ this -> instanceURLRepo -> get ( ) ; $ url .= '/services/apexrest' ; $ url .= $ customURI ; $ parameters = [ ] ; if ( isset ( $ options [ 'parameters' ] ) ) { $ parameters = array_replace_recursive ( $ parameters , $ options [ 'parameters' ] ) ; $ url...
Request to a custom Apex REST endpoint .
57,406
protected function storeVersion ( ) { $ versions = $ this -> versions ( ) ; $ this -> storeConfiguredVersion ( $ versions ) ; $ this -> storeLatestVersion ( $ versions ) ; }
Checks to see if version is specified in configuration and if not then assign the latest version number available to the user s instance . Once a version number is determined it will be stored in the user s storage with the version key .
57,407
private function assignExceptions ( RequestException $ ex ) { if ( $ ex -> hasResponse ( ) && $ ex -> getResponse ( ) -> getStatusCode ( ) == 401 ) { throw new TokenExpiredException ( 'Salesforce token has expired' , $ ex ) ; } elseif ( $ ex -> hasResponse ( ) ) { throw new SalesforceException ( 'Salesforce response er...
Method will elaborate on RequestException .
57,408
protected function byteLength ( $ string ) : int { if ( self :: $ isMbStringOverload ) { return mb_strlen ( $ string , '8bit' ) ; } return strlen ( ( binary ) $ string ) ; }
Gets the length of a string in bytes even if mbstring function overloading is turned on
57,409
private function getCombiningClass ( int $ char ) : int { return isset ( $ this -> namePrepData -> normalizeCombiningClasses [ $ char ] ) ? $ this -> namePrepData -> normalizeCombiningClasses [ $ char ] : 0 ; }
Returns the combining class of a certain wide char
57,410
private function applyCanonicalOrdering ( array $ input ) : array { $ needsSwapping = true ; $ inputLength = count ( $ input ) ; while ( $ needsSwapping ) { $ needsSwapping = false ; $ previousClass = $ this -> getCombiningClass ( intval ( $ input [ 0 ] ) ) ; for ( $ outerIndex = 0 ; $ outerIndex < $ inputLength - 1 ; ...
Applies the canonical ordering of a decomposed UCS4 sequence
57,411
private function validate ( $ encoded ) : bool { if ( strpos ( $ encoded , self :: punycodePrefix ) !== 0 ) { return false ; } if ( strlen ( trim ( $ encoded ) ) <= strlen ( self :: punycodePrefix ) ) { return false ; } return true ; }
Checks whether or not the provided string is a valid punycode string
57,412
private function tag ( $ tags ) { $ this -> initialize ( ) ; if ( ! is_array ( $ tags ) ) { $ tags = [ $ tags ] ; } foreach ( $ tags as $ tag ) { if ( ! is_string ( $ tag ) ) { throw new InvalidArgumentException ( sprintf ( 'Cache tag must be string, "%s" given' , is_object ( $ tag ) ? get_class ( $ tag ) : gettype ( $...
Adds a tag to a cache item .
57,413
private function initialize ( ) { if ( $ this -> callable !== null ) { $ func = $ this -> callable ; $ result = $ func ( ) ; $ this -> hasValue = $ result [ 0 ] ; $ this -> value = $ result [ 1 ] ; $ this -> prevTags = isset ( $ result [ 2 ] ) ? $ result [ 2 ] : [ ] ; $ this -> expirationTimestamp = null ; if ( isset (...
If callable is not null execute it an populate this object with values .
57,414
public function index ( ) { $ this -> validate ( ) ; $ results = $ this -> parseRequest ( ) -> addIncludes ( ) -> addFilters ( ) -> addOrdering ( ) -> addPaging ( ) -> modify ( ) -> getResults ( ) -> toArray ( ) ; $ meta = $ this -> getMetaData ( ) ; return ApiResponse :: make ( null , $ results , $ meta ) ; }
Process index page request
57,415
public function show ( ... $ args ) { $ id = last ( func_get_args ( ) ) ; $ this -> validate ( ) ; $ results = $ this -> parseRequest ( ) -> addIncludes ( ) -> addKeyConstraint ( $ id ) -> modify ( ) -> getResults ( true ) -> first ( ) -> toArray ( ) ; $ meta = $ this -> getMetaData ( true ) ; return ApiResponse :: mak...
Process the show request
57,416
protected function addOrdering ( ) { if ( $ this -> parser -> getOrder ( ) ) { $ this -> query -> orderByRaw ( $ this -> parser -> getOrder ( ) ) ; } return $ this ; }
Add sorting to the query . Sorting is similar to SQL queries
57,417
protected function addPaging ( ) { $ limit = $ this -> parser -> getLimit ( ) ; $ offset = $ this -> parser -> getOffset ( ) ; if ( $ offset <= 0 ) { $ skip = 0 ; } else { $ skip = $ offset ; } $ this -> query -> skip ( $ skip ) ; $ this -> query -> take ( $ limit ) ; return $ this ; }
Adds paging limit and offset to SQL query
57,418
protected function getResults ( $ single = false ) { $ customAttributes = call_user_func ( $ this -> model . "::getAppendFields" ) ; $ appends = [ ] ; $ fields = $ this -> parser -> getFields ( ) ; foreach ( $ fields as $ key => $ field ) { if ( in_array ( $ field , $ customAttributes ) ) { $ appends [ ] = $ field ; un...
Runs query and fetches results
57,419
protected function getMetaData ( $ single = false ) { if ( ! $ single ) { $ meta = [ "paging" => [ "links" => [ ] ] ] ; $ limit = $ this -> parser -> getLimit ( ) ; $ pageOffset = $ this -> parser -> getOffset ( ) ; $ current = $ pageOffset ; $ offset = $ this -> query -> getQuery ( ) -> offset ; $ this -> query -> off...
Builds metadata - paging links time to complete request etc
57,420
private function modify ( ) { if ( $ this -> isIndex ( ) ) { $ this -> query = $ this -> modifyIndex ( $ this -> query ) ; } else if ( $ this -> isShow ( ) ) { $ this -> query = $ this -> modifyShow ( $ this -> query ) ; } else if ( $ this -> isDelete ( ) ) { $ this -> query = $ this -> modifyDelete ( $ this -> query )...
Calls the modifyRequestType methods to modify query just before execution
57,421
protected function parseRequest ( ) { if ( request ( ) -> limit ) { if ( request ( ) -> limit <= 0 ) { throw new InvalidLimitException ( ) ; } else if ( request ( ) -> limit > config ( "api.maxLimit" ) ) { throw new MaxLimitException ( ) ; } else { $ this -> limit = request ( ) -> limit ; } } else { $ this -> limit = c...
Parse request and fill the parameters
57,422
public static function make ( $ message = null , $ data = null , $ meta = null ) { $ response = [ ] ; if ( ! empty ( $ message ) ) { $ response [ "message" ] = $ message ; } if ( $ data !== null && is_array ( $ data ) ) { $ response [ "data" ] = $ data ; } if ( $ meta !== null && is_array ( $ meta ) ) { $ response [ "m...
Make new success response
57,423
public static function exception ( ApiException $ exception ) { $ returnResponse = \ Response :: make ( $ exception -> jsonSerialize ( ) ) ; $ returnResponse -> setStatusCode ( $ exception -> getStatusCode ( ) ) ; return $ returnResponse ; }
Handle api exception an return proper error response
57,424
protected function createFileName ( $ fileName ) { return $ this -> parseFileName ( $ fileName ) . $ this -> suffix ( ) . $ this -> config -> fileExtension ( ) ; }
Create file name .
57,425
protected function parseFileName ( $ fileName ) { return preg_replace_callback ( '#(\[.*\])#U' , function ( $ matches ) { $ format = str_replace ( [ '[' , ']' ] , [ ] , $ matches [ 1 ] ) ; return $ this -> now -> format ( $ format ) ; } , $ fileName ) ; }
Parse file name to include date in it .
57,426
protected function getListenClosure ( SqlLogger $ logger ) { return function ( $ query , $ bindings = null , $ time = null ) use ( $ logger ) { $ logger -> log ( $ query , $ bindings , $ time ) ; } ; }
Get closure that will be used for listening executed database queries .
57,427
public function log ( $ query , array $ bindings = null , $ time = null ) { ++ $ this -> queryNumber ; try { $ sqlQuery = $ this -> query -> get ( $ this -> queryNumber , $ query , $ bindings , $ time ) ; $ this -> writer -> save ( $ sqlQuery ) ; } catch ( Exception $ e ) { $ this -> app [ 'log' ] -> notice ( "Cannot l...
Log query .
57,428
public function getLine ( SqlQuery $ query ) { $ replace = [ '[origin]' => $ this -> originLine ( ) , '[query_nr]' => $ query -> number ( ) , '[datetime]' => Carbon :: now ( ) -> toDateTimeString ( ) , '[query_time]' => $ this -> time ( $ query -> time ( ) ) , '[query]' => $ this -> queryLine ( $ query ) , '[separator]...
Get formatted line .
57,429
protected function getArtisanLine ( ) { $ command = $ this -> app [ 'request' ] -> server ( 'argv' , [ ] ) ; if ( is_array ( $ command ) ) { $ command = implode ( ' ' , $ command ) ; } return $ command ; }
Get Artisan line .
57,430
protected function removeNewLines ( $ sql ) { if ( ! $ this -> config -> newLinesToSpaces ( ) ) { return $ sql ; } return preg_replace ( $ this -> wrapRegex ( $ this -> notInsideQuotes ( '\v' , false ) ) , ' ' , $ sql ) ; }
Remove new lines from SQL to keep it in single line if possible .
57,431
protected function replaceBindings ( $ sql , array $ bindings ) { $ generalRegex = $ this -> getRegex ( ) ; foreach ( $ this -> formatBindings ( $ bindings ) as $ key => $ binding ) { $ regex = is_numeric ( $ key ) ? $ generalRegex : $ this -> getNamedParameterRegex ( $ key ) ; $ sql = preg_replace ( $ regex , $ this -...
Replace bindings .
57,432
protected function getNamedParameterRegex ( $ name ) { if ( mb_substr ( $ name , 0 , 1 ) == ':' ) { $ name = mb_substr ( $ name , 1 ) ; } return $ this -> wrapRegex ( $ this -> notInsideQuotes ( '\:' . preg_quote ( $ name ) , false ) ) ; }
Get regex to be used for named parameter with given name .
57,433
protected function formatBindings ( $ bindings ) { foreach ( $ bindings as $ key => $ binding ) { if ( $ binding instanceof DateTime ) { $ bindings [ $ key ] = $ binding -> format ( 'Y-m-d H:i:s' ) ; } elseif ( is_string ( $ binding ) ) { $ bindings [ $ key ] = str_replace ( "'" , "\\'" , $ binding ) ; } } return $ bin...
Format bindings values .
57,434
protected function notInsideQuotes ( $ string , $ quote = true ) { if ( $ quote ) { $ string = preg_quote ( $ string ) ; } return '(?:""|"(?:[^"]|\\")*?[^\\\]")(*SKIP)(*F)|' . $ string . '|' . '(?:\\\'\\\'|\'(?:[^\']|\\\')*?[^\\\]\')(*SKIP)(*F)|' . $ string ; }
Create partial regex to find given text not inside quotes .
57,435
public function save ( SqlQuery $ query ) { $ this -> createDirectoryIfNotExists ( $ query -> number ( ) ) ; $ line = $ this -> formatter -> getLine ( $ query ) ; if ( $ this -> shouldLogQuery ( $ query ) ) { $ this -> saveLine ( $ line , $ this -> fileName -> getForAllQueries ( ) , $ this -> shouldOverrideFile ( $ que...
Save queries to log .
57,436
protected function createDirectoryIfNotExists ( $ queryNumber ) { if ( $ queryNumber == 1 && ! file_exists ( $ directory = $ this -> directory ( ) ) ) { mkdir ( $ directory , 0777 , true ) ; } }
Create directory if it does not exist yet .
57,437
protected function shouldLogQuery ( SqlQuery $ query ) { return $ this -> config -> logAllQueries ( ) && preg_match ( $ this -> config -> allQueriesPattern ( ) , $ query -> raw ( ) ) ; }
Verify whether query should be logged .
57,438
protected function shouldLogSlowQuery ( SqlQuery $ query ) { return $ this -> config -> logSlowQueries ( ) && $ query -> time ( ) >= $ this -> config -> slowLogTime ( ) && preg_match ( $ this -> config -> slowQueriesPattern ( ) , $ query -> raw ( ) ) ; }
Verify whether slow query should be logged .
57,439
protected function saveLine ( $ line , $ fileName , $ override = false ) { file_put_contents ( $ this -> directory ( ) . DIRECTORY_SEPARATOR . $ fileName , $ line , $ override ? 0 : FILE_APPEND ) ; }
Save data to log file .
57,440
public function getRequestStandardParameter ( ) { $ settings = $ this -> get ( PayoneConstants :: PAYONE ) ; $ standardParameter = new PayoneStandardParameterTransfer ( ) ; $ standardParameter -> setEncoding ( $ settings [ PayoneConstants :: PAYONE_CREDENTIALS_ENCODING ] ) ; $ standardParameter -> setMid ( $ settings [...
Fetches parameters that are common for all requests to Payone API .
57,441
public function manageMandate ( QuoteTransfer $ quoteTransfer ) { $ manageMandateTransfer = new PayoneManageMandateTransfer ( ) ; $ manageMandateTransfer -> setBankCountry ( $ quoteTransfer -> getPayment ( ) -> getPayoneDirectDebit ( ) -> getBankcountry ( ) ) ; $ manageMandateTransfer -> setBankAccount ( $ quoteTransfe...
Performs ManageMandate request to Payone API .
57,442
public function stringify ( $ server , $ secret , $ original , $ commands ) { if ( count ( $ commands ) > 0 ) { $ commandPath = implode ( '/' , $ commands ) ; $ imgPath = sprintf ( '%s/%s' , $ commandPath , $ original ) ; } else { $ imgPath = $ original ; } $ signature = $ secret ? self :: sign ( $ imgPath , $ secret )...
Produce a URL to an image on a Thumbor server according to the specified options .
57,443
public function toArray ( ) { $ commands = array ( ) ; $ maybeAppend = function ( $ command ) use ( & $ commands ) { if ( $ command ) $ commands [ ] = ( string ) $ command ; } ; if ( $ this -> metadataOnly ) { $ commands [ ] = 'meta' ; } $ maybeAppend ( $ this -> trim ) ; $ maybeAppend ( $ this -> crop ) ; $ maybeAppen...
Stringify and return commands as an array .
57,444
public function install ( $ name , $ version = null , $ migrate = true , $ seed = true , $ publish = true ) { if ( $ this -> installed ( $ name ) ) { throw new Exceptions \ HookAlreadyInstalledException ( "Hook [{$name}] is already installed." ) ; } event ( new Events \ InstallingHook ( $ name ) ) ; if ( $ this -> loca...
Install hook .
57,445
public function uninstall ( $ name , $ delete = false , $ unmigrate = true , $ unseed = true , $ unpublish = true ) { if ( ! $ this -> installed ( $ name ) ) { throw new Exceptions \ HookNotInstalledException ( "Hook [{$name}] is not installed." ) ; } $ hook = $ this -> hook ( $ name ) ; $ hook -> loadJson ( ) ; event ...
Uninstall a hook .
57,446
public function update ( $ name , $ version , $ migrate = true , $ seed = true , $ publish = true , $ force = false ) { if ( ! $ this -> downloaded ( $ name ) ) { throw new Exceptions \ HookNotFoundException ( "Hook [{$name}] not found." ) ; } if ( ! $ this -> installed ( $ name ) ) { throw new Exceptions \ HookNotInst...
Update hook .
57,447
public function enable ( $ name ) { if ( ! $ this -> downloaded ( $ name ) ) { throw new Exceptions \ HookNotFoundException ( "Hook [{$name}] not found." ) ; } if ( ! $ this -> installed ( $ name ) ) { throw new Exceptions \ HookNotInstalledException ( "Hook [{$name}] not installed." ) ; } if ( $ this -> enabled ( $ na...
Enable hook .
57,448
public function disable ( $ name ) { if ( ! $ this -> downloaded ( $ name ) ) { throw new Exceptions \ HookNotFoundException ( "Hook [{$name}] not found." ) ; } if ( ! $ this -> installed ( $ name ) ) { throw new Exceptions \ HookNotInstalledException ( "Hook [{$name}] not installed." ) ; } if ( ! $ this -> enabled ( $...
Disable a hook .
57,449
public function make ( $ name ) { $ studlyCase = studly_case ( $ name ) ; if ( $ this -> downloaded ( $ name ) ) { throw new Exceptions \ HookAlreadyExistsException ( "Hook [{$name}] already exists." ) ; } event ( new Events \ MakingHook ( $ name ) ) ; if ( ! $ this -> filesystem -> isDirectory ( base_path ( 'hooks' ) ...
Make hook .
57,450
public function enabled ( $ name ) { return isset ( $ this -> hooks [ $ name ] ) && $ this -> hooks [ $ name ] -> enabled ; }
Check if hook is enabled .
57,451
public function downloaded ( $ name ) { if ( $ this -> local ( $ name ) ) { return $ this -> filesystem -> isDirectory ( base_path ( "hooks/{$name}" ) ) && $ this -> filesystem -> exists ( base_path ( "hooks/{$name}/composer.json" ) ) ; } return $ this -> filesystem -> isDirectory ( base_path ( "vendor/{$name}" ) ) ; }
Check if hook is downloaded .
57,452
public function hook ( $ name ) { if ( ! $ this -> downloaded ( $ name ) ) { throw new Exceptions \ HookNotFoundException ( "Hook [{$name}] not found." ) ; } if ( ! $ this -> installed ( $ name ) ) { throw new Exceptions \ HookNotInstalledException ( "Hook [{$name}] not installed." ) ; } return $ this -> hooks [ $ name...
Get hook information .
57,453
public function type ( $ name ) { $ hook = $ this -> hooks ( ) -> where ( 'name' , $ name ) -> first ( ) ; if ( ! is_null ( $ hook ) ) { return $ hook -> type ; } }
Get type of hook .
57,454
public function getRemoteDetails ( $ name ) { $ remote = json_decode ( file_get_contents ( $ this -> getRemote ( ) . "/api/hooks/{$name}.json" ) , true ) ; if ( $ remote [ 'exists' ] !== true ) { throw new \ InvalidArgumentException ( "Hook [{$name}] does not exists." ) ; } return $ remote ; }
Get hook details from remote .
57,455
public function readJsonFile ( $ localsIncluded = [ ] ) { $ hooks = [ ] ; if ( ! $ this -> filesystem -> exists ( base_path ( 'hooks' ) ) ) { $ this -> filesystem -> makeDirectory ( base_path ( 'hooks' ) ) ; } if ( ! $ this -> filesystem -> exists ( base_path ( 'hooks/hooks.json' ) ) ) { $ this -> filesystem -> put ( b...
Read hooks . json file .
57,456
public function remakeJson ( ) { $ json = json_encode ( [ 'last_remote_check' => ( ! is_null ( $ this -> lastRemoteCheck ) ? $ this -> lastRemoteCheck -> timestamp : null ) , 'hooks' => $ this -> hooks ( ) , ] , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; file_put_contents ( base_path ( 'hooks/hooks.json' ) , $ json...
Remake hooks . json file .
57,457
protected function migrateHook ( Hook $ hook ) { $ migrations = ( array ) $ hook -> getComposerHookKey ( 'migrations' , [ ] ) ; foreach ( $ migrations as $ path ) { if ( $ this -> filesystem -> isDirectory ( $ hook -> getPath ( ) . '/' . $ path ) ) { $ this -> migrator -> run ( $ this -> realPath ( [ $ path ] , $ hook ...
Run migrations found for a specific hook .
57,458
protected function unmigrateHook ( Hook $ hook ) { $ migrations = ( array ) $ hook -> getComposerHookKey ( 'migrations' , [ ] ) ; foreach ( $ migrations as $ path ) { if ( $ this -> filesystem -> isDirectory ( $ hook -> getPath ( ) . '/' . $ path ) ) { $ this -> migrator -> reset ( $ this -> realPath ( [ $ path ] , $ h...
Rollback migrations found for a specific hook .
57,459
protected function seedHook ( Hook $ hook ) { $ folders = ( array ) $ hook -> getComposerHookKey ( 'seeders' , [ ] ) ; $ basePath = $ hook -> getPath ( ) . '/' ; $ this -> runSeeders ( $ folders , $ basePath ) ; }
Run seeders found for a specific hook .
57,460
protected function unpublishHook ( Hook $ hook ) { $ folders = ( array ) $ hook -> getComposerHookKey ( 'assets' , [ ] ) ; $ basePath = $ hook -> getPath ( ) . '/' ; $ filesystem = $ this -> filesystem ; foreach ( $ folders as $ location => $ publish ) { $ publishPath = base_path ( $ publish ) ; if ( ! $ realLocation =...
Unpublish assets found for a specific hook .
57,461
protected function runSeeders ( $ folders , $ basePath ) { $ filesystem = $ this -> filesystem ; $ this -> realPath ( $ folders , $ basePath ) -> each ( function ( $ folder ) use ( $ filesystem ) { if ( $ filesystem -> isDirectory ( $ folder ) ) { $ files = $ filesystem -> files ( $ folder ) ; } else { $ files = [ new ...
Run seeder files .
57,462
protected function realPath ( array $ paths , $ basePath = '' ) { return collect ( $ paths ) -> map ( function ( $ path ) use ( $ basePath ) { return realpath ( $ basePath . $ path ) ; } ) -> filter ( function ( $ path ) { return $ path ; } ) ; }
Get collection of realpath paths .
57,463
protected function makeTemponaryBackup ( Hook $ hook ) { $ folder = $ this -> createTempFolder ( ) ; $ this -> filesystem -> copyDirectory ( $ hook -> getPath ( ) , $ folder ) ; $ this -> tempDirectories [ $ hook -> name ] = $ folder ; }
Make temponary backup of hook .
57,464
public function registerHookProviders ( ) { $ hooks = $ this -> app [ 'hooks' ] -> hooks ( ) -> where ( 'enabled' , true ) ; $ loader = AliasLoader :: getInstance ( ) ; foreach ( $ hooks as $ hook ) { foreach ( $ hook -> getProviders ( ) as $ provider ) { $ this -> app -> register ( $ provider ) ; } foreach ( $ hook ->...
Register Hook Service Providers .
57,465
public function reverseTransform ( $ value ) { if ( empty ( $ value ) ) { return null ; } $ tagPrefixLength = strlen ( $ this -> newTagPrefix ) ; $ cleanValue = substr ( $ value , $ tagPrefixLength ) ; $ valuePrefix = substr ( $ value , 0 , $ tagPrefixLength ) ; if ( $ valuePrefix == $ this -> newTagPrefix ) { $ entity...
Transform single id value to an entity
57,466
public function getSharedDirectory ( ) { $ result = self :: DEFAULT_SHARED_DIR ; if ( $ this -> hasOption ( 'sharedDirectory' ) && ! empty ( $ this -> getOption ( 'sharedDirectory' ) ) ) { $ sharedPath = $ this -> getOption ( 'sharedDirectory' ) ; if ( preg_match ( '/(^|\/)\.\.(\/|$)/' , $ sharedPath ) ) { throw new In...
Returns the shared directory
57,467
public function setReleasesDirectory ( $ releasesDirectory ) { if ( preg_match ( '/(^|\/)\.\.(\/|$)/' , $ releasesDirectory ) ) { throw new InvalidConfigurationException ( sprintf ( '"../" is not allowed in the releases directory "%s"' , $ releasesDirectory ) , 1380870750 ) ; } $ this -> releasesDirectory = trim ( $ re...
Sets the releases directory
57,468
public function getOptions ( ) { return array_merge ( $ this -> options , [ 'deploymentPath' => $ this -> getDeploymentPath ( ) , 'releasesPath' => $ this -> getReleasesPath ( ) , 'sharedPath' => $ this -> getSharedPath ( ) ] ) ; }
Get all options defined on this application instance
57,469
public function getOption ( $ key ) { switch ( $ key ) { case 'deploymentPath' : return $ this -> getDeploymentPath ( ) ; case 'releasesPath' : return $ this -> getReleasesPath ( ) ; case 'sharedPath' : return $ this -> getSharedPath ( ) ; default : return $ this -> options [ $ key ] ; } }
Get an option defined on this application instance
57,470
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ this -> input = $ input ; $ this -> output = $ output ; $ configurationPath = $ input -> getOption ( 'configurationPath' ) ; $ deploymentName = $ input -> getArgument ( 'deploymentName' ) ; $ deployment = $ this -> factory -> getDeploy...
Prints configuration for the
57,471
protected function printApplications ( array $ applications , Workflow $ workflow ) { $ this -> output -> writeln ( PHP_EOL . 'Applications:' . PHP_EOL ) ; foreach ( $ applications as $ application ) { $ this -> output -> writeln ( ' <success>' . $ application -> getName ( ) . ':</success>' ) ; $ this -> output -> wri...
Prints configuration for each defined application
57,472
protected function printStages ( Application $ application , array $ stages , array $ tasks ) { foreach ( $ stages as $ stage ) { $ this -> output -> writeln ( ' <comment>' . $ stage . ':</comment>' ) ; foreach ( [ 'before' , 'tasks' , 'after' ] as $ stageStep ) { $ output = '' ; foreach ( [ '_' , $ application ->...
Prints stages and contained tasks for given application
57,473
private function printBeforeAfterTasks ( array $ tasks , $ applicationName , $ task , $ step , & $ output ) { $ label = $ applicationName === '_' ? 'for all applications' : 'for application ' . $ applicationName ; if ( isset ( $ tasks [ $ step ] [ $ applicationName ] [ $ task ] ) ) { foreach ( $ tasks [ $ step ] [ $ ap...
Print all tasks before or after a task
57,474
public function initialize ( ) { if ( $ this -> initialized ) { throw new SurfException ( 'Already initialized' , 1335976472 ) ; } if ( $ this -> workflow === null ) { $ this -> workflow = new SimpleWorkflow ( ) ; } foreach ( $ this -> applications as $ application ) { $ application -> registerTasks ( $ this -> workflo...
Initialize the deployment
57,475
public function deploy ( ) { $ this -> logger -> notice ( 'Deploying ' . $ this -> name . ' (' . $ this -> releaseIdentifier . ')' ) ; $ this -> workflow -> run ( $ this ) ; }
Run this deployment
57,476
public function simulate ( ) { $ this -> setDryRun ( true ) ; $ this -> logger -> notice ( 'Simulating ' . $ this -> name . ' (' . $ this -> releaseIdentifier . ')' ) ; $ this -> workflow -> run ( $ this ) ; }
Simulate this deployment without executing tasks
57,477
public function getNodes ( ) { $ nodes = [ ] ; foreach ( $ this -> applications as $ application ) { foreach ( $ application -> getNodes ( ) as $ node ) { $ nodes [ $ node -> getName ( ) ] = $ node ; } } return $ nodes ; }
Get all nodes of this deployment
57,478
public function getNode ( $ name ) { if ( $ name === 'localhost' ) { $ node = new Node ( 'localhost' ) ; $ node -> onLocalhost ( ) ; return $ node ; } $ nodes = $ this -> getNodes ( ) ; return isset ( $ nodes [ $ name ] ) ? $ nodes [ $ name ] : null ; }
Get a node by name
57,479
public function rollback ( $ dryRun = false ) { $ this -> logger -> notice ( 'Rollback deployment ' . $ this -> name . ' (' . $ this -> releaseIdentifier . ')' ) ; $ this -> setWorkflow ( new RollbackWorkflow ( ) ) ; $ this -> initialize ( ) ; if ( $ dryRun ) { $ this -> setDryRun ( true ) ; } $ this -> workflow -> run...
Rollback a deployment
57,480
public function createOutput ( ) { if ( $ this -> output === null ) { $ this -> output = new ConsoleOutput ( ) ; $ this -> output -> getFormatter ( ) -> setStyle ( 'b' , new OutputFormatterStyle ( null , null , [ 'bold' ] ) ) ; $ this -> output -> getFormatter ( ) -> setStyle ( 'i' , new OutputFormatterStyle ( 'black' ...
Create the output
57,481
public function getDeployment ( $ deploymentName , $ configurationPath = null , $ simulateDeployment = true , $ initialize = true , $ forceDeployment = false ) { $ deployment = $ this -> createDeployment ( $ deploymentName , $ configurationPath ) ; if ( $ deployment -> getLogger ( ) === null ) { $ logger = $ this -> cr...
Get the deployment object
57,482
public function getDeploymentNames ( $ path = null ) { $ path = $ this -> getDeploymentsBasePath ( $ path ) ; $ files = glob ( Files :: concatenatePaths ( [ $ path , '*.php' ] ) ) ; return array_map ( function ( $ file ) use ( $ path ) { return substr ( $ file , strlen ( $ path ) + 1 , - 4 ) ; } , $ files ) ; }
Get available deployment names
57,483
public function getDeploymentsBasePath ( $ path = null ) { $ localDeploymentDescription = @ realpath ( './.surf' ) ; if ( ! $ path && is_dir ( $ localDeploymentDescription ) ) { $ path = $ localDeploymentDescription ; } $ path = $ path ? : Files :: concatenatePaths ( [ $ this -> getHomeDir ( ) , 'deployments' ] ) ; $ t...
Get the root path of the surf deployment declarations
57,484
public function getWorkspacesBasePath ( $ path = null ) { $ workspacesBasePath = getenv ( 'SURF_WORKSPACE' ) ; if ( ! $ workspacesBasePath ) { $ path = $ path ? : $ this -> getHomeDir ( ) ; if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { if ( $ workspacesBasePath = getenv ( 'LOCALAPPDATA' ) ) { $ workspacesBasePath = ...
Get the base path to local workspaces
57,485
protected function createDeployment ( $ deploymentName , $ path = null ) { $ deploymentConfigurationPath = $ this -> getDeploymentsBasePath ( $ path ) ; $ workspacesBasePath = $ this -> getWorkspacesBasePath ( ) ; if ( empty ( $ deploymentName ) ) { $ deploymentNames = $ this -> getDeploymentNames ( $ path ) ; if ( cou...
Get a deployment object by deployment name
57,486
protected function getHomeDir ( ) { $ home = getenv ( 'SURF_HOME' ) ; if ( ! $ home ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { if ( ! getenv ( 'APPDATA' ) ) { throw new \ RuntimeException ( 'The APPDATA or SURF_HOME environment variable must be set for composer to run correctly' ) ; } $ home = Files :: concat...
Get the home directory
57,487
protected function createLogger ( ) { if ( $ this -> logger === null ) { $ consoleHandler = new ConsoleHandler ( $ this -> createOutput ( ) ) ; $ this -> logger = new Logger ( 'TYPO3 Surf' , [ $ consoleHandler ] ) ; } return $ this -> logger ; }
Create a logger instance
57,488
protected function ensureDirectoryExists ( $ dir ) { if ( ! file_exists ( $ dir ) && ! @ mkdir ( $ dir , 0777 , true ) && ! is_dir ( $ dir ) ) { throw new InvalidConfigurationException ( sprintf ( 'Directory "%s" cannot be created!' , $ dir ) , 1451862775 ) ; } }
Check that the directory exists
57,489
public function registerTasks ( Workflow $ workflow , Deployment $ deployment ) { $ this -> setOption ( GenericCreateDirectoriesTask :: class . '[directories]' , $ this -> getDirectories ( ) ) ; $ this -> setOption ( CreateSymlinksTask :: class . '[symlinks]' , $ this -> getSymlinks ( ) ) ; if ( $ this -> hasOption ( '...
Register tasks for the base application
57,490
public function addSymlinks ( array $ symlinks ) { foreach ( $ symlinks as $ linkPath => $ sourcePath ) { $ this -> addSymlink ( $ linkPath , $ sourcePath ) ; } return $ this ; }
Register an array of additional symlinks to be created for the application
57,491
protected function checkIfMandatoryOptionsExist ( ) { if ( ! $ this -> hasOption ( 'version' ) ) { throw new InvalidConfigurationException ( '"version" option needs to be defined. Example: 1.0.0-beta2' , 1314187396 ) ; } if ( ! $ this -> hasOption ( 'projectName' ) ) { throw new InvalidConfigurationException ( '"projec...
Check if all necessary options to run are set
57,492
public function simulate ( $ command , Node $ node , Deployment $ deployment ) { if ( $ node -> isLocalhost ( ) ) { $ command = $ this -> prepareCommand ( $ command ) ; $ deployment -> getLogger ( ) -> debug ( '... (localhost): "' . $ command . '"' ) ; } else { $ command = $ this -> prepareCommand ( $ command ) ; $ dep...
Simulate a command by just outputting what would be executed
57,493
protected function executeLocalCommand ( $ command , Deployment $ deployment , $ logOutput = true ) { $ command = $ this -> prepareCommand ( $ command ) ; $ deployment -> getLogger ( ) -> debug ( '(localhost): "' . $ command . '"' ) ; return $ this -> executeProcess ( $ deployment , $ command , $ logOutput , '> ' ) ; }
Execute a shell command locally
57,494
protected function executeRemoteCommand ( $ command , Node $ node , Deployment $ deployment , $ logOutput = true ) { $ command = $ this -> prepareCommand ( $ command ) ; $ deployment -> getLogger ( ) -> debug ( '$' . $ node -> getName ( ) . ': "' . $ command . '"' ) ; if ( $ node -> hasOption ( 'remoteCommandExecutionH...
Execute a shell command via SSH
57,495
protected function prepareCommand ( $ command ) { if ( is_string ( $ command ) ) { return trim ( $ command ) ; } if ( is_array ( $ command ) ) { return implode ( ' && ' , $ command ) ; } throw new TaskExecutionException ( 'Command must be string or array, ' . gettype ( $ command ) . ' given.' , 1312454906 ) ; }
Prepare a command
57,496
public function removeTask ( $ removeTask , Application $ application = null ) { $ removeApplicationName = $ application instanceof Application ? $ application -> getName ( ) : null ; $ applicationRemovalGuardClause = function ( $ applicationName ) use ( $ removeApplicationName ) { return null !== $ removeApplicationNa...
Remove the given task from all stages and applications
57,497
protected function addTaskToStage ( $ tasks , $ stage , Application $ application = null , $ step = 'tasks' ) { if ( ! is_array ( $ tasks ) ) { $ tasks = [ $ tasks ] ; } $ applicationName = $ application !== null ? $ application -> getName ( ) : '_' ; if ( ! isset ( $ this -> tasks [ 'stage' ] [ $ applicationName ] [ $...
Add the given tasks to a step in a stage and optionally a specific application
57,498
public function addTask ( $ tasks , $ stage , Application $ application = null ) { $ this -> addTaskToStage ( $ tasks , $ stage , $ application ) ; return $ this ; }
Add the given tasks for a stage and optionally a specific application
57,499
public function afterTask ( $ task , $ tasks , Application $ application = null ) { if ( ! is_array ( $ tasks ) ) { $ tasks = [ $ tasks ] ; } $ applicationName = $ application !== null ? $ application -> getName ( ) : '_' ; if ( ! isset ( $ this -> tasks [ 'after' ] [ $ applicationName ] [ $ task ] ) ) { $ this -> task...
Add tasks that shall be executed after the given task