My own ServiceProviders were working fine until I ported them across to a fresh install of L5. The composer is not loading and so I'm not getting any of my composer code.
// remove the rest for brevity
'Illuminate\View\ViewServiceProvider',
'Laravel\Socialite\SocialiteServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Intervention\Image\ImageServiceProvider',
/*
* My own app SP
*/
'App\Providers\TranslatorServiceProvider',
My SP
/**
* Registers the decorated translator
*
* @return void
*/
public function register()
{
$this->registerLang();
$this->registerAuthComposer();
}
/**
* Register views to composer
*/
private function registerAuthComposer()
{
$this->app->view->composer('auth.register.start', TranslatorComposer::class );
$this->app->view->composer('auth.login', TranslatorComposer::class );
}
/**
* Register the service provider.
*
* @return void
*/
private function registerLang()
{
$this->registerLoader();
$this->app->singleton('translator', function($app)
{
$loader = $app['translation.loader'];
$locale = $app['config']['app.locale'];
$trans = new Translator($loader, $locale);
$trans->setFallback($app['config']['app.fallback_locale']);
return new TranslatorDecorator($trans, $app['config'], $this->app );
});
}
\\ excluding the 2 other Laravel methods
My Decorator class
class TranslatorDecorator extends TranslatorResource implements TranslatorInterface
{
/**
* Supported Locales
*
* @var array
*/
protected $supportedLocales;
/**
* Current locale
*
* @var string
*/
protected $currentLocale = false;
/**
* An array that contains all routes that should be translated
*
* @var array
*/
protected $translatedRoutes = array();
/**
* Default locale
*
* @var string
*/
protected $defaultLocale;
/**
* The actual translator instance
* @var \Illuminate\Translation\Translator
*/
protected $translator;
/**
* @var Repository
*/
protected $configRepository;
/**
* @var Application
*/
protected $app;
/**
* creates an instance of the decorator
* @param TranslatorInterface $translator
*/
public function __construct(TranslatorInterface $translator, Repository $configRepository, Application $app )
{
$this->translator = $translator;
$this->configRepository = $configRepository;
$this->defaultLocale = $this->configRepository->get('app.locale');
$this->app = $app;
$this->request = $this->app['request'];
}
\\ lang methods below