Вызов конструктора родительского класса в PHP

У меня есть контроллер

use API\Transformer\DataTransformer; use API\Data\DataRepositoryInterface; class DataController extends APIController implements APIInterface { protected $data; public function __construct(DataRepositoryInterface $data) { $this->data = $data; } 

И в APIController

 use League\Fractal\Resource\Collection; use League\Fractal\Resource\Item; use League\Fractal\Manager; class APIController extends Controller { protected $statusCode = 200; public function __construct(Manager $fractal) { $this->fractal = $fractal; // Are we going to try and include embedded data? $this->fractal->setRequestedScopes(explode(',', Input::get('embed'))); $this->fireDebugFilters(); } 

Ничто внутри APIController __construct() , я попробовал parent::__construct(); но это ошибки (см. ошибку ниже), когда я пытаюсь вызвать класс из APIController

 Argument 1 passed to APIController::__construct() must be an instance of League\Fractal\Manager, none given, called in /srv/app.dev/laravel/app/controllers/DataController.php on line 12 and defined 

Другими словами, он пытается создать экземпляр конструктора APIController в DataController. Как я могу заставить его вызвать конструктор APIController перед DataController ?

Ваш конструктор должен передать все необходимые объекты в родительский constuctor. Родительскому конструктору нужен объект Manager, поэтому вы должны передать его, если хотите его вызвать. Если DataRepositoryInterface не является Менеджером, вам нужно передать менеджера в свой конструктор childs или создать экземпляр объекта, необходимый для передачи родительскому классу.

  class DataController extends APIController implements APIInterface { protected $data; public function __construct(Manager $fractal, DataRepositoryInterface $data) { parent::__construct($fractal); $this->data = $data; } } 

Или вы можете создать экземпляр Менеджера внутри вашего контура

  class DataController extends APIController implements APIInterface { protected $data; public function __construct(DataRepositoryInterface $data) { $fractal = new Manager(); //or whatever gets an instance of a manager parent::__construct($fractal); $this->data = $data; } }