PHP Class VersionPress\Api\VersionPressApi

Afficher le fichier Open project: versionpress/versionpress Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( GitRepository $gitRepository, Reverter $reverter, SynchronizationProcess $synchronizationProcess, CommitMessageParser $commitMessageParser )
canRevert ( ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
checkPermissions ( WP_REST_Request $request ) : WP_Erro\WP_Error | boolean
commit ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error Creates manual commit. Adds everything to stage.
discardChanges ( ) : WP_REST_Response Discards all changes in working directory.
displayWelcomePanel ( ) : WP_REST_Response
getAutocompleteConfig ( ) : WP_REST_Response Returns current WP configuration for autocomplete component.
getCommits ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
getDiff ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error Returns diff of given commit.
getError ( string $status ) : WP_Error
getGitStatus ( ) : WP_REST_Response Returns list of files with modification types.
hideWelcomePanel ( ) : WP_REST_Response
registerRoutes ( ) Register the VersionPress related routes
revertCommits ( string $reverterMethod, array $commits ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
rollbackToCommit ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
shouldUpdate ( WP_REST_Request $request )
undoCommits ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

Private Methods

Méthode Description
convertChangeInfo ( $changeInfo )
convertChangeInfoList ( $getChangeInfoList )
getFileChanges ( Commit $commit, boolean $skipVpdbFiles ) : array
getInitialCommitHash ( ) : string
handleAsAdminSectionRoute ( string $routeHandler ) : Closure Adds WP_ADMIN constant before route handling function is called. Routes calls are than evaluated as called in admin section of WordPress even if the routes are called using AJAX (WordPress native function is_admin() evaluates call correctly.
handleErrorOutput ( callable | string $routeHandler ) : Closure Prevents unexpected output from displaying to output, adds it to the response json instead.
registerRestRoute ( $route, $args = [], $override = false )
updateDatabase ( $status )

Method Details

__construct() public méthode

public __construct ( GitRepository $gitRepository, Reverter $reverter, SynchronizationProcess $synchronizationProcess, CommitMessageParser $commitMessageParser )
$gitRepository VersionPress\Git\GitRepository
$reverter VersionPress\Git\Reverter
$synchronizationProcess VersionPress\Synchronizers\SynchronizationProcess
$commitMessageParser VersionPress\ChangeInfos\CommitMessageParser

canRevert() public méthode

public canRevert ( ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

checkPermissions() public méthode

public checkPermissions ( WP_REST_Request $request ) : WP_Erro\WP_Error | boolean
$request WP_REST_Request
Résultat WP_Erro\WP_Error | boolean

commit() public méthode

Creates manual commit. Adds everything to stage.
public commit ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$request WP_REST_Request
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

discardChanges() public méthode

Discards all changes in working directory.
public discardChanges ( ) : WP_REST_Response
Résultat WP_REST_Response

displayWelcomePanel() public méthode

public displayWelcomePanel ( ) : WP_REST_Response
Résultat WP_REST_Response

getAutocompleteConfig() public méthode

Returns current WP configuration for autocomplete component.
public getAutocompleteConfig ( ) : WP_REST_Response
Résultat WP_REST_Response

getCommits() public méthode

public getCommits ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$request WP_REST_Request
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

getDiff() public méthode

If there's provided no commit hash, returns diff of working directory and HEAD.
public getDiff ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$request WP_REST_Request
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

getError() public méthode

public getError ( string $status ) : WP_Error
$status string
Résultat WP_Error

getGitStatus() public méthode

Example: [ ["A", "some-file.txt"], ["M", "other-file.txt"] ] Modification types: ?? - untracked file A - added file M - modified file D - deleted file
public getGitStatus ( ) : WP_REST_Response
Résultat WP_REST_Response

hideWelcomePanel() public méthode

public hideWelcomePanel ( ) : WP_REST_Response
Résultat WP_REST_Response

registerRoutes() public méthode

Register the VersionPress related routes
public registerRoutes ( )

revertCommits() public méthode

public revertCommits ( string $reverterMethod, array $commits ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$reverterMethod string
$commits array
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

rollbackToCommit() public méthode

public rollbackToCommit ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$request WP_REST_Request
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error

shouldUpdate() public méthode

public shouldUpdate ( WP_REST_Request $request )
$request WP_REST_Request

undoCommits() public méthode

public undoCommits ( WP_REST_Request $request ) : WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error
$request WP_REST_Request
Résultat WP_REST_Respons\WP_REST_Response | WP_Erro\WP_Error