idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
226,900
public function actionDelete ( ) { if ( isset ( $ _GET [ 'name' ] ) ) { $ name = $ _GET [ 'name' ] ; $ am = Yii :: app ( ) -> getAuthManager ( ) ; $ item = $ am -> getAuthItem ( $ name ) ; if ( $ item instanceof CAuthItem ) { $ am -> removeAuthItem ( $ name ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ...
Deletes the item with the given name .
226,901
public function actionRemoveParent ( $ itemName , $ parentName ) { $ am = Yii :: app ( ) -> getAuthManager ( ) ; if ( $ am -> hasItemChild ( $ parentName , $ itemName ) ) { $ am -> removeItemChild ( $ parentName , $ itemName ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ; } } $ this -> redirect ( array ...
Removes the parent from the item with the given name .
226,902
public function actionRemoveChild ( $ itemName , $ childName ) { $ am = Yii :: app ( ) -> getAuthManager ( ) ; if ( $ am -> hasItemChild ( $ itemName , $ childName ) ) { $ am -> removeItemChild ( $ itemName , $ childName ) ; if ( $ am instanceof CPhpAuthManager ) { $ am -> save ( ) ; } } $ this -> redirect ( array ( 'v...
Removes the child from the item with the given name .
226,903
protected function getItemChildOptions ( $ itemName ) { $ options = array ( ) ; $ am = Yii :: app ( ) -> getAuthManager ( ) ; $ item = $ am -> getAuthItem ( $ itemName ) ; if ( $ item instanceof CAuthItem ) { $ exclude = $ am -> getAncestors ( $ itemName ) ; $ exclude [ $ itemName ] = $ item ; $ exclude = array_merge (...
Returns a list of possible children for the item with the given name .
226,904
protected function getValidChildTypes ( ) { $ validTypes = array ( ) ; switch ( $ this -> type ) { case CAuthItem :: TYPE_OPERATION : break ; case CAuthItem :: TYPE_TASK : $ validTypes [ ] = CAuthItem :: TYPE_OPERATION ; break ; case CAuthItem :: TYPE_ROLE : $ validTypes [ ] = CAuthItem :: TYPE_OPERATION ; $ validTypes...
Returns a list of the valid child types for the given type .
226,905
public function flushAccess ( $ itemName , $ userId ) { if ( ( $ cache = $ this -> getCache ( ) ) !== null ) { $ cacheKey = $ this -> resolveCacheKey ( $ itemName , $ userId ) ; return $ cache -> delete ( $ cacheKey ) ; } return false ; }
Flushes the access cache for the specified user .
226,906
protected function getCache ( ) { return $ this -> cachingDuration > 0 && $ this -> cacheID !== false ? Yii :: app ( ) -> getComponent ( $ this -> cacheID ) : null ; }
Returns the caching component for this component .
226,907
private function parseClassMetadata ( $ class ) { $ metadata = new ClassMetadata ( $ class ) ; $ this -> loadParentMetadata ( $ metadata ) ; $ this -> loadInterfaceMetadata ( $ metadata ) ; $ this -> loader -> loadClassMetadata ( $ metadata ) ; $ this -> setParsedClass ( $ class , $ metadata ) ; if ( $ this -> cache !=...
Reads class metadata for a new and unparsed class
226,908
protected function loadParentMetadata ( ClassMetadataInterface $ metadata ) { $ parent = $ metadata -> getReflectionClass ( ) -> getParentClass ( ) ; if ( $ parent ) { $ metadata -> mergeRules ( $ this -> getClassMetadata ( $ parent -> getName ( ) ) ) ; } }
Checks if the class being parsed has a parent and cascades parsing to its parent
226,909
public function getLoginUrl ( string $ redirectUrl , array $ permissions = [ 'public_profile' ] , ? string $ stateParam = null ) : string { $ helper = $ this -> facebook -> getRedirectLoginHelper ( ) ; if ( isset ( $ stateParam ) ) { $ helper -> getPersistentDataHandler ( ) -> set ( 'state' , $ stateParam ) ; } $ url =...
Creates Response that redirects person to FB for authorization and back
226,910
public static function fromSha ( $ sha , $ baseUrl , ClientInterface $ client ) { $ url = Project :: getProjectBaseFromUrl ( $ baseUrl ) . '/git/trees' ; return static :: get ( $ sha , $ url , $ client ) ; }
Get the Tree object for an SHA hash .
226,911
public function getObject ( $ path ) { if ( $ path === '' || $ path === '.' ) { return $ this ; } $ data = $ this -> getObjectData ( $ path ) ; if ( $ data === false ) { return false ; } if ( $ data [ 'type' ] === 'blob' ) { return Blob :: fromSha ( $ data [ 'sha' ] , $ this -> getUri ( ) , $ this -> client ) ; } elsei...
Get an object in this tree .
226,912
private function getObjectData ( $ path ) { foreach ( $ this -> tree as $ objectData ) { if ( $ objectData [ 'path' ] === $ path ) { return $ objectData ; } } return false ; }
Find an object definition by its path .
226,913
private function getObjectRecursive ( $ path ) { $ tree = $ object = $ this ; foreach ( $ this -> splitPath ( $ path ) as $ part ) { $ object = $ tree -> getObject ( $ part ) ; if ( ! $ object instanceof Tree ) { return $ object ; } $ tree = $ object ; } return $ object ; }
Get an object recursively in this tree .
226,914
public function triggerHook ( ) { $ hookUrl = $ this -> getLink ( '#hook' ) ; $ options = [ ] ; $ options [ 'json' ] = new \ stdClass ( ) ; $ options [ 'auth' ] = null ; $ this -> sendRequest ( $ hookUrl , 'post' , $ options ) ; }
Trigger the integration s web hook .
226,915
public static function listValidationErrors ( BadResponseException $ exception ) { $ response = $ exception -> getResponse ( ) ; if ( $ response && $ response -> getStatusCode ( ) === 400 ) { $ response -> getBody ( ) -> seek ( 0 ) ; $ data = $ response -> json ( ) ; if ( isset ( $ data [ 'detail' ] ) && is_array ( $ d...
Process an API exception to list integration validation errors .
226,916
public function getActivities ( ) { if ( ! isset ( $ this -> data [ '_embedded' ] [ 'activities' ] ) ) { return [ ] ; } $ activities = [ ] ; foreach ( $ this -> data [ '_embedded' ] [ 'activities' ] as $ data ) { $ activities [ ] = new Activity ( $ data , $ this -> baseUrl , $ this -> client ) ; } return $ activities ;...
Get activities embedded in the result .
226,917
public function getEntity ( ) { if ( ! isset ( $ this -> data [ '_embedded' ] [ 'entity' ] ) || ! isset ( $ this -> resourceClass ) ) { throw new \ Exception ( "No entity found in result" ) ; } $ data = $ this -> data [ '_embedded' ] [ 'entity' ] ; $ resourceClass = $ this -> resourceClass ; return new $ resourceClass ...
Get the entity embedded in the result .
226,918
public function getRawContent ( ) { if ( $ this -> size == 0 ) { return '' ; } if ( $ this -> encoding === 'base64' ) { $ raw = base64_decode ( $ this -> content , true ) ; if ( $ raw === false ) { throw new \ RuntimeException ( 'Failed to decode content' ) ; } return $ raw ; } throw new \ RuntimeException ( 'Unrecogni...
Get the raw content of the file .
226,919
public static function underscore ( $ camel_cased_word ) { $ word = $ camel_cased_word ; $ word = preg_replace ( '/\\\/' , '/' , $ word ) ; $ acronym_regex = static :: inflections ( ) -> acronym_regex ; $ word = preg_replace_callback ( "/(?:([A-Za-z\d])|^)({$acronym_regex})(?=\b|[^a-z])/" , function ( $ matches ) { ret...
Makes an underscored lowercase form from the expression in the string .
226,920
public static function humanize ( $ lower_case_and_underscored_word ) { $ result = $ lower_case_and_underscored_word ; foreach ( static :: inflections ( ) -> humans as $ rule => $ replacement ) { if ( ( $ result = preg_replace ( $ rule , $ replacement , $ result , 1 ) ) ) break ; } ; $ result = preg_replace ( '/_id$/' ...
Capitalizes the first word and turns underscores into spaces and strips a trailing _id if any . Like + titleize + this is meant for creating pretty output .
226,921
private static function apply_inflections ( $ word , $ rules ) { $ result = $ word ; preg_match ( '/\b\w+\Z/' , strtolower ( $ result ) , $ matches ) ; if ( empty ( $ word ) || array_search ( $ matches [ 0 ] , static :: inflections ( ) -> uncountables ) !== false ) { return $ result ; } else { foreach ( $ rules as $ ru...
Applies inflection rules for + singularize + and + pluralize + .
226,922
private function load ( ) { if ( ! $ this -> loaded && isset ( $ this -> storage ) ) { $ this -> data = $ this -> storage -> load ( $ this -> id ) ; $ this -> original = $ this -> data ; $ this -> loaded = true ; } }
Load session data if storage is defined .
226,923
public static function validatePublicKey ( $ value ) { $ value = preg_replace ( '/\s+/' , ' ' , $ value ) ; if ( ! strpos ( $ value , ' ' ) ) { return false ; } list ( $ type , $ key ) = explode ( ' ' , $ value , 3 ) ; if ( ! in_array ( $ type , static :: $ allowedAlgorithms ) || base64_decode ( $ key , true ) === fals...
Validate an SSH public key .
226,924
public static function get ( $ id , $ collectionUrl = null , ClientInterface $ client ) { try { $ url = $ collectionUrl ? rtrim ( $ collectionUrl , '/' ) . '/' . urlencode ( $ id ) : $ id ; $ request = new Request ( 'get' , $ url ) ; $ data = self :: send ( $ request , $ client ) ; return new static ( $ data , $ url , ...
Get a resource by its ID .
226,925
public static function send ( RequestInterface $ request , ClientInterface $ client , array $ options = [ ] ) { $ response = null ; try { $ response = $ client -> send ( $ request , $ options ) ; $ body = $ response -> getBody ( ) -> getContents ( ) ; $ data = [ ] ; if ( $ body ) { $ response -> getBody ( ) -> seek ( 0...
Send a Guzzle request .
226,926
protected function sendRequest ( $ url , $ method = 'get' , array $ options = [ ] ) { return $ this -> send ( new Request ( $ method , $ url ) , $ this -> client , $ options ) ; }
A simple helper function to send an HTTP request .
226,927
protected static function checkNew ( array $ data ) { $ errors = [ ] ; if ( $ missing = array_diff ( static :: getRequired ( ) , array_keys ( $ data ) ) ) { $ errors [ ] = 'Missing: ' . implode ( ', ' , $ missing ) ; } foreach ( $ data as $ key => $ value ) { $ errors += static :: checkProperty ( $ key , $ value ) ; } ...
Validate a new resource .
226,928
public static function wrapCollection ( array $ data , $ baseUrl , ClientInterface $ client ) { $ resources = [ ] ; foreach ( $ data as $ item ) { $ resources [ ] = new static ( $ item , $ baseUrl , $ client ) ; } return $ resources ; }
Create an array of resource instances from a collection s JSON data .
226,929
protected function runOperation ( $ op , $ method = 'post' , array $ body = [ ] ) { if ( ! $ this -> operationAvailable ( $ op , true ) ) { throw new OperationUnavailableException ( "Operation not available: $op" ) ; } $ options = [ ] ; if ( ! empty ( $ body ) ) { $ options [ 'json' ] = $ body ; } $ request = new Reque...
Execute an operation on the resource .
226,930
protected function runLongOperation ( $ op , $ method = 'post' , array $ body = [ ] ) { $ result = $ this -> runOperation ( $ op , $ method , $ body ) ; $ activities = $ result -> getActivities ( ) ; if ( count ( $ activities ) !== 1 ) { trigger_error ( sprintf ( "Expected one activity, found %d" , count ( $ activities...
Run a long - running operation .
226,931
public function hasProperty ( $ property , $ lazyLoad = true ) { if ( ! $ this -> isProperty ( $ property ) ) { return false ; } if ( ! array_key_exists ( $ property , $ this -> data ) && $ lazyLoad ) { $ this -> ensureFull ( ) ; } return array_key_exists ( $ property , $ this -> data ) ; }
Check whether a property exists in the resource .
226,932
public function getProperty ( $ property , $ required = true , $ lazyLoad = true ) { if ( ! $ this -> hasProperty ( $ property , $ lazyLoad ) ) { if ( $ required ) { throw new \ InvalidArgumentException ( "Property not found: $property" ) ; } return null ; } return $ this -> data [ $ property ] ; }
Get a property of the resource .
226,933
public function delete ( ) { $ data = $ this -> sendRequest ( $ this -> getUri ( ) , 'delete' ) ; return new Result ( $ data , $ this -> getUri ( ) , $ this -> client , get_called_class ( ) ) ; }
Delete the resource .
226,934
public function update ( array $ values ) { if ( $ errors = $ this -> checkUpdate ( $ values ) ) { $ message = "Cannot update resource due to validation error(s): " . implode ( '; ' , $ errors ) ; throw new \ InvalidArgumentException ( $ message ) ; } $ data = $ this -> runOperation ( 'edit' , 'patch' , $ values ) -> g...
Update the resource .
226,935
protected static function checkUpdate ( array $ values ) { $ errors = [ ] ; foreach ( $ values as $ key => $ value ) { $ errors += static :: checkProperty ( $ key , $ value ) ; } return $ errors ; }
Validate values for update .
226,936
public function refresh ( array $ options = [ ] ) { $ request = new Request ( 'get' , $ this -> getUri ( ) ) ; $ this -> setData ( self :: send ( $ request , $ this -> client , $ options ) ) ; $ this -> isFull = true ; }
Refresh the resource .
226,937
public function operationAvailable ( $ op , $ refreshDuringCheck = false ) { if ( ! $ this -> isFull ) { $ this -> refresh ( ) ; $ refreshDuringCheck = false ; } $ available = $ this -> isOperationAvailable ( $ op ) ; if ( $ available ) { return true ; } if ( $ refreshDuringCheck ) { $ this -> refresh ( ) ; $ available...
Check whether an operation is available on the resource .
226,938
public function getLink ( $ rel , $ absolute = true ) { if ( ! $ this -> hasLink ( $ rel ) ) { throw new \ InvalidArgumentException ( "Link not found: $rel" ) ; } $ url = $ this -> data [ '_links' ] [ $ rel ] [ 'href' ] ; if ( $ absolute && strpos ( $ url , '//' ) === false ) { $ url = $ this -> makeAbsoluteUrl ( $ url...
Get a link for a given resource relation .
226,939
protected function makeAbsoluteUrl ( $ relativeUrl , $ baseUrl = null ) { $ baseUrl = $ baseUrl ? : $ this -> baseUrl ; if ( empty ( $ baseUrl ) ) { throw new \ RuntimeException ( 'No base URL' ) ; } $ base = \ GuzzleHttp \ Psr7 \ uri_for ( $ baseUrl ) ; return $ base -> withPath ( $ relativeUrl ) -> __toString ( ) ; }
Make a URL absolute based on the base URL .
226,940
public function getProperties ( $ lazyLoad = true ) { if ( $ lazyLoad ) { $ this -> ensureFull ( ) ; } $ keys = $ this -> getPropertyNames ( ) ; return array_intersect_key ( $ this -> data , array_flip ( $ keys ) ) ; }
Get an array of this resource s properties and their values .
226,941
public function disable ( ) { if ( ! $ this -> getProperty ( 'is_enabled' ) ) { return new Result ( [ ] , $ this -> baseUrl , $ this -> client , get_called_class ( ) ) ; } return $ this -> update ( [ 'is_enabled' => false ] ) ; }
Disable the variable .
226,942
protected function getDefaultDirectory ( ) { $ default = $ this -> getHomeDirectory ( ) . '/.platformsh/.session' ; if ( $ this -> canWrite ( $ default ) ) { return $ default ; } $ temp = sys_get_temp_dir ( ) . '/.platformsh-client/.session' ; if ( $ this -> canWrite ( $ temp ) ) { return $ temp ; } throw new \ Runtime...
Get the default directory for session files .
226,943
protected function getHomeDirectory ( ) { $ home = getenv ( 'HOME' ) ; if ( ! $ home && ( $ userProfile = getenv ( 'USERPROFILE' ) ) ) { $ home = $ userProfile ; } if ( ! $ home || ! is_dir ( $ home ) ) { throw new \ RuntimeException ( 'Could not determine home directory' ) ; } return $ home ; }
Finds the user s home directory .
226,944
public function getSubscriptionId ( ) { if ( $ this -> hasProperty ( 'subscription_id' , false ) ) { return $ this -> getProperty ( 'subscription_id' ) ; } if ( isset ( $ this -> data [ 'subscription' ] [ 'license_uri' ] ) ) { return basename ( $ this -> data [ 'subscription' ] [ 'license_uri' ] ) ; } throw new \ Runti...
Get the subscription ID for the project .
226,945
public function getGitUrl ( ) { if ( ! $ this -> hasProperty ( 'repository' , false ) ) { $ host = parse_url ( $ this -> getUri ( ) , PHP_URL_HOST ) ; return "{$this->id}@git.{$host}:{$this->id}.git" ; } $ repository = $ this -> getProperty ( 'repository' ) ; return $ repository [ 'url' ] ; }
Get the Git URL for the project .
226,946
public function addUser ( $ user , $ role , $ byUuid = false ) { $ property = $ byUuid ? 'user' : 'email' ; $ body = [ $ property => $ user , 'role' => $ role ] ; return ProjectAccess :: create ( $ body , $ this -> getLink ( 'access' ) , $ this -> client ) ; }
Add a new user to a project .
226,947
public function addDomain ( $ name , array $ ssl = [ ] ) { $ body = [ 'name' => $ name ] ; if ( ! empty ( $ ssl ) ) { $ body [ 'ssl' ] = $ ssl ; } return Domain :: create ( $ body , $ this -> getLink ( 'domains' ) , $ this -> client ) ; }
Add a domain to the project .
226,948
public function addIntegration ( $ type , array $ data = [ ] ) { $ body = [ 'type' => $ type ] + $ data ; return Integration :: create ( $ body , $ this -> getLink ( 'integrations' ) , $ this -> client ) ; }
Add an integration to the project .
226,949
public function getActivities ( $ limit = 0 , $ type = null , $ startsAt = null ) { $ options = [ ] ; if ( $ type !== null ) { $ options [ 'query' ] [ 'type' ] = $ type ; } if ( $ startsAt !== null ) { $ options [ 'query' ] [ 'starts_at' ] = Activity :: formatStartsAt ( $ startsAt ) ; } $ activities = Activity :: getCo...
Get a list of project activities .
226,950
public function setVariable ( $ name , $ value , $ json = false , $ visibleBuild = true , $ visibleRuntime = true , $ sensitive = false ) { if ( ! is_scalar ( $ value ) ) { $ value = json_encode ( $ value ) ; $ json = true ; } $ values = [ 'value' => $ value , 'is_json' => $ json , 'visible_build' => $ visibleBuild , '...
Set a variable .
226,951
public function addCertificate ( $ certificate , $ key , array $ chain = [ ] ) { $ options = [ 'key' => $ key , 'certificate' => $ certificate , 'chain' => $ chain ] ; return Certificate :: create ( $ options , $ this -> getUri ( ) . '/certificates' , $ this -> client ) ; }
Add a certificate to the project .
226,952
public static function getProjectBaseFromUrl ( $ url ) { if ( preg_match ( '#/api/projects/([^/]+)#' , $ url , $ matches ) ) { return uri_for ( $ url ) -> withPath ( '/api/projects/' . $ matches [ 1 ] ) -> __toString ( ) ; } throw new \ RuntimeException ( 'Failed to find project ID from URL: ' . $ url ) ; }
Find the project base URL from another project resource s URL .
226,953
public function getParams ( ) { $ filters = array_filter ( $ this -> filters , function ( $ value ) { return $ value !== null ; } ) ; $ filters = array_map ( function ( $ value ) { return is_array ( $ value ) ? [ 'value' => $ value , 'operator' => 'IN' ] : $ value ; } , $ filters ) ; return count ( $ filters ) ? [ 'fil...
Get the URL query parameters .
226,954
public function getDefaultProvider ( ) { if ( isset ( $ this -> defaultProvider ) ) { return $ this -> getProvider ( $ this -> defaultProvider ) ; } $ providerLabels = array_keys ( $ this -> providers ) ; return $ this -> providers [ $ providerLabels [ 0 ] ] ; }
Returns the default provider . If no default provider is set the first one will be returned .
226,955
public function render ( array $ options = array ( ) , $ provider = null ) { if ( isset ( $ provider ) ) { $ options [ 'provider' ] = $ provider ; } $ request = $ this -> getCurrentRequest ( ) ; if ( ! isset ( $ request ) ) { throw new RuntimeException ( 'Comments rendering needs the Request.' ) ; } return $ this -> co...
Triggers comments rendering .
226,956
public function renderForContent ( ContentInfo $ contentInfo , array $ options = array ( ) , $ provider = null ) { if ( isset ( $ provider ) ) { $ options [ 'provider' ] = $ provider ; } $ request = $ this -> getCurrentRequest ( ) ; if ( ! isset ( $ request ) ) { throw new RuntimeException ( 'Comments rendering needs t...
Triggers comments rendering for a given ContentInfo object .
226,957
private function revokeTokens ( ) { $ revocations = array_filter ( [ 'refresh_token' => $ this -> session -> get ( 'refreshToken' ) , 'access_token' => $ this -> session -> get ( 'accessToken' ) , ] ) ; $ url = uri_for ( $ this -> config [ 'accounts' ] ) -> withPath ( $ this -> config [ 'revoke_url' ] ) -> __toString (...
Revokes the access and refresh tokens saved in the session .
226,958
protected function saveToken ( AccessToken $ token ) { if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] === 'access' ) { return ; } foreach ( $ token -> jsonSerialize ( ) as $ name => $ value ) { if ( isset ( $ this -> storageKeys [ $ name ] ) ) { $ this -> session -> set ( $ this -> stora...
Save an access token to the session .
226,959
protected function loadToken ( ) { if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] === 'access' ) { return new AccessToken ( [ 'access_token' => $ this -> config [ 'api_token' ] , 'expires' => 2147483647 , ] ) ; } if ( ! $ this -> session -> get ( $ this -> storageKeys [ 'access_token' ] ...
Load the current access token .
226,960
protected function getOauthMiddleware ( ) { if ( ! $ this -> oauthMiddleware ) { if ( ! $ this -> isLoggedIn ( ) ) { throw new \ RuntimeException ( 'Not logged in' ) ; } $ grant = new ClientCredentials ( ) ; $ grantOptions = [ ] ; if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] !== 'acces...
Get an OAuth2 middleware to add to Guzzle clients .
226,961
protected function doRender ( array $ options ) { $ template = isset ( $ options [ 'template' ] ) ? $ options [ 'template' ] : $ this -> getDefaultTemplate ( ) ; unset ( $ options [ 'template' ] ) ; return $ this -> templateEngine -> render ( $ template , $ options ) ; }
Renders the template with provided options . template option allows to override the default template for rendering .
226,962
public static function fromData ( array $ data ) { $ policies = [ ] ; foreach ( isset ( $ data [ 'schedule' ] ) ? $ data [ 'schedule' ] : [ ] as $ policyData ) { $ policies [ ] = new Policy ( $ policyData [ 'interval' ] , $ policyData [ 'count' ] ) ; } return new static ( $ policies , isset ( $ data [ 'manual_count' ] ...
Instantiates a backup configuration object from config data .
226,963
public static function array_flatten ( array $ array ) { $ index = 0 ; $ count = count ( $ array ) ; while ( $ index < $ count ) { if ( is_array ( $ array [ $ index ] ) ) { array_splice ( $ array , $ index , 1 , $ array [ $ index ] ) ; } else { ++ $ index ; } $ count = count ( $ array ) ; } return $ array ; }
Make multidimensional array flat
226,964
public static function array_delete ( array & $ data , $ key ) { if ( array_key_exists ( $ key , $ data ) ) { $ value = $ data [ $ key ] ; unset ( $ data [ $ key ] ) ; return $ value ; } }
Deletes entry from array and return its value
226,965
public function getCurrentDeployment ( ) { $ deployment = EnvironmentDeployment :: get ( 'current' , $ this -> getUri ( ) . '/deployments' , $ this -> client ) ; if ( ! $ deployment ) { throw new EnvironmentStateException ( 'Current deployment not found' , $ this ) ; } return $ deployment ; }
Get the current deployment of this environment .
226,966
public function getHeadCommit ( ) { $ base = Project :: getProjectBaseFromUrl ( $ this -> getUri ( ) ) . '/git/commits' ; return Commit :: get ( $ this -> head_commit , $ base , $ this -> client ) ; }
Get the Git commit for the HEAD of this environment .
226,967
public function getSshUrl ( $ app = '' ) { $ urls = $ this -> getSshUrls ( ) ; if ( isset ( $ urls [ $ app ] ) ) { return $ urls [ $ app ] ; } return $ this -> constructLegacySshUrl ( $ app ) ; }
Get the SSH URL for the environment .
226,968
private function constructLegacySshUrl ( ) { if ( ! $ this -> hasLink ( 'ssh' ) ) { $ id = $ this -> data [ 'id' ] ; if ( ! $ this -> isActive ( ) ) { throw new EnvironmentStateException ( "No SSH URL found for environment '$id'. It is not currently active." , $ this ) ; } throw new OperationUnavailableException ( "No ...
Get the SSH URL via the legacy ssh link .
226,969
public function getSshUrls ( ) { $ prefix = 'pf:ssh:' ; $ prefixLength = strlen ( $ prefix ) ; $ sshUrls = [ ] ; foreach ( $ this -> data [ '_links' ] as $ rel => $ link ) { if ( strpos ( $ rel , $ prefix ) === 0 && isset ( $ link [ 'href' ] ) ) { $ sshUrls [ substr ( $ rel , $ prefixLength ) ] = $ this -> convertSshUr...
Returns a list of SSH URLs keyed by app name .
226,970
public function getPublicUrl ( ) { if ( ! $ this -> hasLink ( 'public-url' ) ) { $ id = $ this -> data [ 'id' ] ; if ( ! $ this -> isActive ( ) ) { throw new EnvironmentStateException ( "No public URL found for environment '$id'. It is not currently active." , $ this ) ; } throw new OperationUnavailableException ( "No ...
Get the public URL for the environment .
226,971
public function synchronize ( $ data = false , $ code = false , $ rebase = false ) { if ( ! $ data && ! $ code ) { throw new \ InvalidArgumentException ( 'Nothing to synchronize: you must specify $data or $code' ) ; } $ body = [ 'synchronize_data' => $ data , 'synchronize_code' => $ code , ] ; if ( $ rebase ) { $ body ...
Synchronize an environment with its parent .
226,972
public function setVariable ( $ name , $ value , $ json = false , $ enabled = true , $ sensitive = false ) { if ( ! is_scalar ( $ value ) ) { $ value = json_encode ( $ value ) ; $ json = true ; } $ values = [ 'value' => $ value , 'is_json' => $ json , 'is_enabled' => $ enabled ] ; if ( $ sensitive ) { $ values [ 'is_se...
Set a variable
226,973
public function getRouteUrls ( ) { $ routes = [ ] ; if ( isset ( $ this -> data [ '_links' ] [ 'pf:routes' ] ) ) { foreach ( $ this -> data [ '_links' ] [ 'pf:routes' ] as $ route ) { $ routes [ ] = $ route [ 'href' ] ; } } return $ routes ; }
Get the resolved URLs for the environment s routes .
226,974
public function addUser ( $ user , $ role , $ byUuid = true ) { $ property = $ byUuid ? 'user' : 'email' ; $ body = [ $ property => $ user , 'role' => $ role ] ; return EnvironmentAccess :: create ( $ body , $ this -> getLink ( '#manage-access' ) , $ this -> client ) ; }
Add a new user to the environment .
226,975
public function addBackupPolicy ( Policy $ policy ) { $ backups = isset ( $ this -> data [ 'backups' ] ) ? $ this -> data [ 'backups' ] : [ ] ; $ backups [ 'schedule' ] [ ] = [ 'interval' => $ policy -> getInterval ( ) , 'count' => $ policy -> getCount ( ) , ] ; if ( ! isset ( $ backups [ 'manual_count' ] ) ) { $ backu...
Add a scheduled backup policy .
226,976
public static function parameterize ( $ string , $ sep = '-' ) { $ parameterized_string = static :: transliterate ( $ string ) ; $ parameterized_string = preg_replace ( '/[^a-z0-9\-_]+/i' , $ sep , $ parameterized_string ) ; if ( ! ( is_null ( $ sep ) || empty ( $ sep ) ) ) { $ re_sep = preg_quote ( $ sep ) ; $ paramet...
Replaces special characters in a string so that it may be used as part of a pretty URL .
226,977
public function getProject ( $ id , $ hostname = null , $ https = true ) { foreach ( $ this -> getProjects ( ) as $ project ) { if ( $ project -> id === $ id ) { return $ project ; } } if ( $ hostname !== null ) { return $ this -> getProjectDirect ( $ id , $ hostname , $ https ) ; } if ( $ url = $ this -> locateProject...
Get a single project by its ID .
226,978
public function getProjects ( $ reset = false ) { $ data = $ this -> getAccountInfo ( $ reset ) ; $ client = $ this -> connector -> getClient ( ) ; $ projects = [ ] ; foreach ( $ data [ 'projects' ] as $ project ) { $ projects [ ] = new Project ( $ project , $ project [ 'endpoint' ] , $ client ) ; } return $ projects ;...
Get the logged - in user s projects .
226,979
public function getAccountInfo ( $ reset = false ) { if ( ! isset ( $ this -> accountInfo ) || $ reset ) { $ url = $ this -> accountsEndpoint . 'me' ; try { $ this -> accountInfo = $ this -> simpleGet ( $ url ) ; } catch ( BadResponseException $ e ) { throw ApiResponseException :: create ( $ e -> getRequest ( ) , $ e -...
Get account information for the logged - in user .
226,980
private function simpleGet ( $ url , array $ options = [ ] ) { return ( array ) \ GuzzleHttp \ json_decode ( $ this -> getConnector ( ) -> getClient ( ) -> request ( 'get' , $ url , $ options ) -> getBody ( ) -> getContents ( ) , true ) ; }
Get a URL and return the JSON - decoded response .
226,981
public function getProjectDirect ( $ id , $ hostname , $ https = true ) { $ scheme = $ https ? 'https' : 'http' ; $ collection = "$scheme://$hostname/api/projects" ; return Project :: get ( $ id , $ collection , $ this -> connector -> getClient ( ) ) ; }
Get a single project at a known location .
226,982
protected function locateProject ( $ id ) { $ url = $ this -> accountsEndpoint . 'projects/' . rawurlencode ( $ id ) ; try { $ result = $ this -> simpleGet ( $ url ) ; } catch ( BadResponseException $ e ) { $ response = $ e -> getResponse ( ) ; $ ignoredErrorCodes = [ 400 , 403 , 404 ] ; if ( $ response && in_array ( $...
Locate a project by ID .
226,983
public function getSshKeys ( $ reset = false ) { $ data = $ this -> getAccountInfo ( $ reset ) ; return SshKey :: wrapCollection ( $ data [ 'ssh_keys' ] , $ this -> accountsEndpoint , $ this -> connector -> getClient ( ) ) ; }
Get the logged - in user s SSH keys .
226,984
public function getSshKey ( $ id ) { $ url = $ this -> accountsEndpoint . 'ssh_keys' ; return SshKey :: get ( $ id , $ url , $ this -> connector -> getClient ( ) ) ; }
Get a single SSH key by its ID .
226,985
public function addSshKey ( $ value , $ title = null ) { $ values = $ this -> cleanRequest ( [ 'value' => $ value , 'title' => $ title ] ) ; $ url = $ this -> accountsEndpoint . 'ssh_keys' ; return SshKey :: create ( $ values , $ url , $ this -> connector -> getClient ( ) ) ; }
Add an SSH public key to the logged - in user s account .
226,986
public function createSubscription ( $ region , $ plan = 'development' , $ title = null , $ storage = null , $ environments = null , array $ activationCallback = null ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; $ values = $ this -> cleanRequest ( [ 'project_region' => $ region , 'plan' => $ plan , 'proje...
Create a new Platform . sh subscription .
226,987
public function getSubscriptions ( ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; return Subscription :: getCollection ( $ url , 0 , [ ] , $ this -> connector -> getClient ( ) ) ; }
Get a list of your Platform . sh subscriptions .
226,988
public function getSubscription ( $ id ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; return Subscription :: get ( $ id , $ url , $ this -> connector -> getClient ( ) ) ; }
Get a subscription by its ID .
226,989
public function getSubscriptionEstimate ( $ plan , $ storage , $ environments , $ users ) { $ options = [ ] ; $ options [ 'query' ] = [ 'plan' => $ plan , 'storage' => $ storage , 'environments' => $ environments , 'user_licenses' => $ users , ] ; try { return $ this -> simpleGet ( $ this -> accountsEndpoint . 'estimat...
Estimate the cost of a subscription .
226,990
public function getPlanRecords ( PlanRecordQuery $ query = null ) { $ url = $ this -> accountsEndpoint . 'records/plan' ; $ options = [ ] ; if ( $ query ) { $ options [ 'query' ] = $ query -> getParams ( ) ; } return PlanRecord :: getCollection ( $ url , 0 , $ options , $ this -> connector -> getClient ( ) ) ; }
Get plan records .
226,991
public function acronym ( $ word ) { $ this -> acronyms [ strtolower ( $ word ) ] = $ word ; $ this -> acronym_regex = implode ( '|' , $ this -> acronyms ) ; }
Specifies a new acronym . An acronym must be specified as it will appear in a camelized string . An underscore string that contains the acronym will retain the acronym when passed to camelize humanize or titleize . A camelized string that contains the acronym will maintain the acronym when titleized or humanized and wi...
226,992
public function plural ( $ rule , $ replacement ) { if ( is_string ( $ rule ) ) { Utils :: array_delete ( $ this -> uncountables , $ rule ) ; } Utils :: array_delete ( $ this -> uncountables , $ replacement ) ; array_unshift ( $ this -> plurals , array ( $ rule , $ replacement ) ) ; }
Specifies a new pluralization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .
226,993
public function singular ( $ rule , $ replacement ) { if ( is_string ( $ rule ) ) { Utils :: array_delete ( $ this -> uncountables , $ rule ) ; } Utils :: array_delete ( $ this -> uncountables , $ replacement ) ; array_unshift ( $ this -> singulars , array ( $ rule , $ replacement ) ) ; }
Specifies a new singularization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .
226,994
public function irregular ( $ singular , $ plural ) { Utils :: array_delete ( $ this -> uncountables , $ singular ) ; Utils :: array_delete ( $ this -> uncountables , $ plural ) ; $ singular_char = substr ( $ singular , 0 , 1 ) ; $ singular_char_upcase = strtoupper ( substr ( $ singular , 0 , 1 ) ) ; $ singular_char_do...
Specifies a new irregular that applies to both pluralization and singularization at the same time . This can only be used for strings not regular expressions . You simply pass the irregular in singular and plural form .
226,995
public function uncountable ( ) { $ words = func_get_args ( ) ; array_push ( $ this -> uncountables , $ words ) ; $ this -> uncountables = Utils :: array_flatten ( $ this -> uncountables ) ; return $ this -> uncountables ; }
Add uncountable words that shouldn t be attempted inflected .
226,996
public static function getErrorDetails ( ResponseInterface $ response ) { $ responseInfoProperties = [ 'message' , 'detail' , 'title' , 'type' , 'error' , 'error_description' , ] ; $ details = '' ; $ response -> getBody ( ) -> seek ( 0 ) ; $ contents = $ response -> getBody ( ) -> getContents ( ) ; try { $ json = \ Guz...
Get more details from the response body to add to error messages .
226,997
public static function fromName ( $ refName , Project $ project , ClientInterface $ client ) { $ url = $ project -> getUri ( ) . '/git/refs' ; return static :: get ( $ refName , $ url , $ client ) ; }
Get a Ref object in a project .
226,998
public function getCommit ( ) { $ data = $ this -> object ; if ( $ data [ 'type' ] !== 'commit' ) { throw new \ RuntimeException ( 'This ref is not a commit' ) ; } $ url = Project :: getProjectBaseFromUrl ( $ this -> getUri ( ) ) . '/git/commits' ; return Commit :: get ( $ data [ 'sha' ] , $ url , $ this -> client ) ; ...
Get the commit for this ref .
226,999
public function wait ( callable $ onPoll = null , $ interval = 2 ) { while ( $ this -> isPending ( ) ) { sleep ( $ interval > 1 ? $ interval : 1 ) ; $ this -> refresh ( ) ; if ( $ onPoll !== null ) { $ onPoll ( $ this ) ; } } }
Wait for the subscription s project to be provisioned .