While reading a famous book on Design patterns. I tried to run this code. But it seems to be illogical, we are injecting Interface via the constructor? Thoughts.
class CustomerController {
protected $repository;
public function __construct(CustomerRepositoryInterface $repo) {
$this->repository = $repo;
}
public function viewAction() {
$customer = $this->repository->getById(1001);
return $customer;
}
Aucun commentaire:
Enregistrer un commentaire