Skip to content

Commit

Permalink
Update Request.zep
Browse files Browse the repository at this point in the history
The Http request service cannot invoke filterService from container.
  • Loading branch information
zikezhang authored Nov 10, 2023
1 parent 37f5eb8 commit 4f58887
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions phalcon/Http/Request.zep
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ use Phalcon\Filter\FilterInterface;
use Phalcon\Http\Message\RequestMethodInterface;
use Phalcon\Http\Request\File;
use Phalcon\Http\Request\FileInterface;
use Phalcon\Filter\FilterFactory;
use Phalcon\Http\Request\Exception;
use Phalcon\Support\Helper\Json\Decode;
use UnexpectedValueException;
@@ -1646,15 +1647,13 @@ class Request extends AbstractInjectionAware implements RequestInterface, Reques

if typeof filterService != "object" {
let container = <DiInterface> this->container;

if container === null {
throw new Exception(
"A dependency injection container is required to access the 'filter' service"
);
if typeof container == "object" && container->has("filter") {
let filter = <FilterInterface> container->getShared("filter"),
this->filterService = filter;
} else {
this->filterService = (new FilterFactory())->newInstance();
}

let filterService = <FilterInterface> container->getShared("filter"),
this->filterService = filterService;
this->filterService = filterService;
}

return this->filterService;

0 comments on commit 4f58887

Please sign in to comment.