stable

Clone or download

Read-only

Introduce ChainOfResponsibility pattern to route Git requests

Part of request #10399: kill Git.class.php with fire In order to split our famous god-object Git.class.php, a solution is to split it in small objects. For example we can have a WebhookRouter that can handle all request related to webhook management (and only them, SRP ftw). By chaining small routers to handle git requests, we can reduce the complexity of Git management. This commit only deals with webhook management. In ChainOfResponsibility pattern we chain the receiving objects and pass the request along the chain until an object handles it. Don't worry, I will not forget the fans of ascii diagrams: request = 【'edit-webhook', ...】 | | process(request); | +----------------+ ‹´ | A router | « Nope! » +----------------+ \ | | | | process(request); | | +-------ˇ--------+ ‹´ | Another router | « Nope! » +----------------+ \ | | | | process(request); | | +-------ˇ--------+ ‹´ | ... | « Nope! » +----------------+ \ | | | | process(request); | | +-------ˇ--------+ ‹´ | Webhook Router | « Yay! I can deal with this request! \o/ » +----------------+ | | | +-------ˇ--------+ | ... | +----------------+ | | | +-------ˇ--------+ | Legacy Git | // This our god-object that will handle all remaining +----------------+ // requests until we move them in dedicated objects Change-Id: I131750e4778fa539e3ef053cb467a84b38614c87

Modified Files

Name
M plugins/git/include/Git.class.php +0 −69 Go to diff View file
A plugins/git/include/Git/GitGodObjectWrapper.php +43 −0 Go to diff View file
A plugins/git/include/Git/Repository/RepositoryFromRequestRetriever.php +92 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/UserCannotAdministrateRepositoryException.php +25 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/WebhookAddController.php +64 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/WebhookController.php +96 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/WebhookDeleteController.php +80 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/WebhookEditController.php +81 −0 Go to diff View file
A plugins/git/include/Git/Repository/Settings/WebhookRouter.php +68 −0 Go to diff View file
A plugins/git/include/Git/RouterLink.php +57 −0 Go to diff View file
M plugins/git/include/GitActions.class.php +0 −78 Go to diff View file
M plugins/git/include/autoload.php +11 −2 Go to diff View file
M plugins/git/include/gitPlugin.class.php +39 −3 Go to diff View file
M plugins/git/tests/GitActionsTest.php +8 −12 Go to diff View file
M plugins/git/tests/GitTest.php +0 −1 Go to diff View file