I'm using the Sentinel bundle for Laravel.
The vendor class UserController has a constructor that injects a bunch of dependencies into it that looks like this:
<?php namespace Sentinel;
use Sentinel\Repo\User\UserInterface;
use Sentinel\Repo\Group\GroupInterface;
use Sentinel\Service\Form\Register\RegisterForm;
use Sentinel\Service\Form\User\UserForm;
use Sentinel\Service\Form\ResendActivation\ResendActivationForm;
use Sentinel\Service\Form\ForgotPassword\ForgotPasswordForm;
use Sentinel\Service\Form\ChangePassword\ChangePasswordForm;
use Sentinel\Service\Form\SuspendUser\SuspendUserForm;
use BaseController, View, Input, Event, Redirect, Session, Config;
class UserController extends BaseController {
protected $user;
protected $group;
protected $registerForm;
protected $userForm;
protected $resendActivationForm;
protected $forgotPasswordForm;
protected $changePasswordForm;
protected $suspendUserForm;
/**
* Instantiate a new UserController
*/
public function __construct(
UserInterface $user,
GroupInterface $group,
RegisterForm $registerForm,
UserForm $userForm,
ResendActivationForm $resendActivationForm,
ForgotPasswordForm $forgotPasswordForm,
ChangePasswordForm $changePasswordForm,
SuspendUserForm $suspendUserForm)
{
$this->user = $user;
$this->group = $group;
$this->registerForm = $registerForm;
$this->userForm = $userForm;
$this->resendActivationForm = $resendActivationForm;
$this->forgotPasswordForm = $forgotPasswordForm;
$this->changePasswordForm = $changePasswordForm;
$this->suspendUserForm = $suspendUserForm;
//Check CSRF token on POST
$this->beforeFilter('Sentinel\csrf', array('on' => array('post', 'put', 'delete')));
// Set up Auth Filters
$this->beforeFilter('Sentinel\auth', array('only' => array('change')));
$this->beforeFilter('Sentinel\inGroup:Admins', array('only' => array('show', 'index', 'create', 'destroy', 'suspend', 'unsuspend', 'ban', 'unban', 'edit', 'update')));
//array('except' => array('create', 'store', 'activate', 'resend', 'forgot', 'reset')));
}
// The rest of the class code...
I've created model class in my app called ExtendedUserController so that I can add functionality to the existing controller. My controller class looks like this currently:
<?php
use Sentinel\UserController;
use Sentinel\Repo\Group\SentryGroup;
class ExtendedUserController extends UserController {
// The rest of the class code...
I don't have a constructor in my class because I'm letting the parent class construct when I extend it.
I have a new model that I would like to add to my controller class. My plan was to inject the dependency in a constructor for the ExtendedUserController and then call `parent::__construct()' to allow the parent class to be extended.
I'm running into errors when loading the class and I'm still green enough to laravel and dependency injection that I'm not exactly sure how to fix it or if this is even the proper way of accomplishing the task:
<?php
use Sentinel\UserController;
use Sentinel\Repo\Group\SentryGroup;
use CustomerLinks;
class ExtendedUserController extends UserController {
protected $customerLinks;
public function __construct(CustomerLinks $customerLinksClass){
$this->customerLinks = $customerLinksClass;
parent::__construct();
}
I'm running into the error:
Argument 1 passed to Sentinel\UserController::__construct() must be an instance of Sentinel\Repo\User\UserInterface, none given, called in /var/www/app/controllers/ExtendedUserController.php on line 15 and defined
If I run the parent constructor, shouldn't the parent's code automatically pass in it's dependencies as outlined in the parent class' code?
Is this not the proper way to add the dependency? Any help and explanation would be greatly appreciated.