-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace Virge\Router\Component\Response; | ||
|
||
use Virge\Router\Component\Response; | ||
use Virge\Router\Service\PipelineService; | ||
use Virge\Virge; | ||
|
||
abstract class Pipe | ||
{ | ||
abstract public function prepareResponse(Response $response); | ||
|
||
public function pipe(Pipe $pipe) { | ||
|
||
} | ||
|
||
protected function getPipelineService() : PipelineService | ||
{ | ||
return Virge::service(PipelineService::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
namespace Virge\Router\Service; | ||
|
||
use Virge\Router\Component\Response; | ||
use Virge\Router\Component\Response\Pipe; | ||
|
||
/** | ||
* Used to pipeline a response to modify and then ultimately send the response | ||
*/ | ||
class PipelineService | ||
{ | ||
protected $pipes = []; | ||
|
||
public function prepareResponse(Response $response) | ||
{ | ||
foreach($this->pipes as $pipe) { | ||
$pipe->prepareResponse($response); | ||
} | ||
|
||
$response->send(false); | ||
} | ||
|
||
public function addPipe(Pipe $pipe) | ||
{ | ||
$this->pipes[] = $pipe; | ||
|
||
return $pipe; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
<?php | ||
|
||
use Virge\Router\Service\{ | ||
PipelineService, | ||
RouterService, | ||
TemplateService | ||
}; | ||
use Virge\Virge; | ||
|
||
/** | ||
* Registers all given handlers with Virge that this Capsule contains | ||
* @author Michael Kramer | ||
*/ | ||
Virge::registerService("router", "\\Virge\\Router\\Service\\RouterService"); | ||
Virge::registerService("templating", "\\Virge\\Router\\Service\\TemplateService"); | ||
|
||
Virge::registerService(PipelineService::class, PipelineService::class); | ||
Virge::registerService("router", RouterService::class); | ||
Virge::registerService("templating", TemplateService::class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters