I want to extend this class Illuminate\Translation\Translator
which extends \Illuminate\Support\NamespacedItemResolver
<?php
namespace Illuminate\Translation;
use Countable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\NamespacedItemResolver;
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
class Translator extends NamespacedItemResolver implements TranslatorContract
{
use Macroable;
}
I extended \Illuminate\Support\NamespacedItemResolver
into my own class
but when I call Translator
its still taking the base class's functions.
which is \Illuminate\Support\NamespacedItemResolver
.
<?php
namespace App\Repositories;
class NamespaceParser extends \Illuminate\Support\NamespacedItemResolver
{
}
UPDATE
created a new Translator class and tried to extend it in the AppServiceProvider
and the below WORKED
public function register()
{
$loader = $this->app['translation.loader'];
// When registering the translator component, we'll need to set the default
// locale as well as the fallback locale. So, we'll grab the application
// configuration so we can easily get both of these values from there.
$locale = $this->app['config']['app.locale'];
$this->app->extend('translator', function () {
new \App\Repositories\Translator($loader, $locale);
});
}