Injecting the repository interface instead of the concrete implementation

parent dccf9d15
......@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Response;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Dashboard\Repositories\WidgetRepository;
use Modules\User\Contracts\Authentication;
use Nwidart\Modules\Repository;
use Nwidart\Modules\Contracts\RepositoryInterface;
class DashboardController extends AdminBaseController
{
......@@ -21,11 +21,11 @@ class DashboardController extends AdminBaseController
private $auth;
/**
* @param Repository $modules
* @param RepositoryInterface $modules
* @param WidgetRepository $widget
* @param Authentication $auth
*/
public function __construct(Repository $modules, WidgetRepository $widget, Authentication $auth)
public function __construct(RepositoryInterface $modules, WidgetRepository $widget, Authentication $auth)
{
parent::__construct();
$this->bootWidgets($modules);
......@@ -87,9 +87,9 @@ class DashboardController extends AdminBaseController
/**
* Boot widgets for all enabled modules
* @param Repository $modules
* @param RepositoryInterface $modules
*/
private function bootWidgets(Repository $modules)
private function bootWidgets(RepositoryInterface $modules)
{
foreach ($modules->enabled() as $module) {
if (! $module->widgets) {
......
......@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\View;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Workshop\Manager\ModuleManager;
use Nwidart\Modules\Module;
use Nwidart\Modules\Repository;
use Nwidart\Modules\Contracts\RepositoryInterface;
use Symfony\Component\Console\Output\BufferedOutput;
class ModulesController extends AdminBaseController
......@@ -19,11 +19,11 @@ class ModulesController extends AdminBaseController
*/
private $moduleManager;
/**
* @var Repository
* @var RepositoryInterface
*/
private $modules;
public function __construct(ModuleManager $moduleManager, Repository $modules)
public function __construct(ModuleManager $moduleManager, RepositoryInterface $modules)
{
parent::__construct();
......
......@@ -4,7 +4,7 @@ use Illuminate\Routing\Router;
/** @var Router $router */
$router->bind('module', function ($module) {
return app(\Nwidart\Modules\Repository::class)->find($module);
return app(\Nwidart\Modules\Contracts\RepositoryInterface::class)->find($module);
});
$router->bind('theme', function ($theme) {
return app(\Modules\Workshop\Manager\ThemeManager::class)->find($theme);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment