Skip to content

Commit 183bfc3

Browse files
authored
Merge pull request #16 from hyperf-cloud/huangzhhui-patch-1
Removed constructor of abstract controller, use annotation inject the requirement
2 parents feca149 + 11ef77f commit 183bfc3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

app/Controller/Controller.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,28 @@
1212

1313
namespace App\Controller;
1414

15+
use Hyperf\Di\Annotation\Inject;
1516
use Hyperf\HttpServer\Contract\RequestInterface;
1617
use Hyperf\HttpServer\Contract\ResponseInterface;
1718
use Psr\Container\ContainerInterface;
1819

1920
abstract class Controller
2021
{
2122
/**
23+
* @Inject
2224
* @var ContainerInterface
2325
*/
2426
protected $container;
2527

2628
/**
29+
* @Inject
2730
* @var RequestInterface
2831
*/
2932
protected $request;
3033

3134
/**
35+
* @Inject
3236
* @var ResponseInterface
3337
*/
3438
protected $response;
35-
36-
public function __construct(ContainerInterface $container)
37-
{
38-
$this->container = $container;
39-
$this->request = $container->get(RequestInterface::class);
40-
$this->response = $container->get(ResponseInterface::class);
41-
}
4239
}

0 commit comments

Comments
 (0)