1. Go to this page and download the library: Download vox/pipeline-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vox / pipeline-bundle example snippets
class PipelineItem
{
/**
* se houver esse método declarado, ele será chamado antes de chamar o __invoke
* e caso ele retone false, não será chamado o __invoke
* essa interface é implicita, não sendo necessário implementar nenhuma interface
*/
public function shouldCall(PipelineContext $context): boolean
{
return true;
}
public function __invoke(PipelineContext $context)
{
//code
}
}
public function __invoke(PipelineContext $context)
{
$event = $context->event;
$event = $context->get('event');
}
class SomeService
{
private $pipelineRunner;
public function __contruct(PipelineRunner $pipelineRunner)
{
$this->pipelineRunner = $pipelineRunner;
}
public function soSomething()
{
$context = new PipelineContext();
$this->pipelineRunner->run($context);
// o pipeline runner é também um callable, pode ser executado como uma função
call_user_func($this->pipelineRunner, $context);
// ou
$this->pipelineRunner($context);
}
}
public function __invoke(PipelineContext $context)
{
//para a execução dessa pipe e vai para a proxima
throw new CannotHandleContextException();
}
public function __invoke(PipelineContext $context)
{
//para a execução dessa pipe e termina a execução, evitando de chamar que chame as proximas
throw new ShouldStopPropagationException();
}
public function __invoke(PipelineContext $context)
{
// se esse metodo for chamado, os proximos itens da pipeline não serão mais chamados
// a execução desse item continua até o final
$context->stopPropagation();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.