Skip to content

Commit 7ea0cd3

Browse files
committed
Pass container instance to pipeline
1 parent 94d29bd commit 7ea0cd3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"suggest": {
1111
"illuminate/database": "Allows to send request with data from model",
12-
"illuminate/pipeline": "Allows to send response data through pipelines"
12+
"illuminate/pipeline": "Allows to send response data through pipelines",
13+
"illuminate/container": "Required to use pipelines"
1314
},
1415
"autoload": {
1516
"psr-4": {

src/Response.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Ivan770\HttpClient\Exceptions\PipelineNotAvailable;
66
use Symfony\Component\HttpClient\Exception\JsonException;
7+
use Illuminate\Container\Container;
78
use Illuminate\Pipeline\Pipeline;
89

910
/**
@@ -18,6 +19,8 @@ class Response
1819

1920
protected $pipeline;
2021

22+
protected $container;
23+
2124
public function __construct($baseResponse)
2225
{
2326
$this->baseResponse = $baseResponse;
@@ -32,10 +35,18 @@ protected function pipelineAvailable()
3235
throw new PipelineNotAvailable("Pipeline class cannot be found");
3336
}
3437

38+
protected function getContainer()
39+
{
40+
if (function_exists("app")) {
41+
$this->container = app();
42+
}
43+
return $this->container;
44+
}
45+
3546
protected function getPipeline()
3647
{
3748
if ($this->pipelineAvailable() && is_null($this->pipeline)) {
38-
$this->pipeline = new Pipeline();
49+
$this->pipeline = new Pipeline($this->getContainer());
3950
}
4051
return $this->pipeline;
4152
}

0 commit comments

Comments
 (0)