Skip to content

Commit

Permalink
Update the readme to illustrate new usage
Browse files Browse the repository at this point in the history
  • Loading branch information
midnite81 committed Jul 29, 2020
1 parent 51a90d3 commit 595ea0f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions usage-laravel.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,34 @@ you could extend the AlphaconService provider and bind as follows;

```php
use Midnite81\Alphacon\AlphaconServiceProvider;
use Midnite81\Alphacon\Contracts\Services\ITranslator;
use Midnite81\Alphacon\Services\Translator;
use Midnite81\Alphacon\Contracts\Services\IMyCustomTranslator;
use Midnite81\Alphacon\Services\MyCustomTranslator;

class ExtendedServiceProvider extends AlphaconServiceProvider
{
public function register(){
parent::register();

$this->app->bind(IMyCustomTranslator::class, function($app) {
new Translator(new MyCustomDictionary());
new MyCustomTranslator(new MyCustomDictionary());
});
}
}
```

You will need to create the interface (IMyCustomTranslator), but you do not need to do
anything else with it. Simply inherit from ITranslator and you'll have all the methods
you require.
You will need to create the interface (IMyCustomTranslator) and extend ITranslator.
Simply inherit from ITranslator and you'll have all the methods you require.

```php
interface IMyCustomTranslator extends \Midnite81\Alphacon\Contracts\Services\ITranslator
{
}
```

You will also nee to create the concrete class (MyCustomTranslator) and extend Translator.

```php
class MyCustomTranslator extends \Midnite81\Alphacon\Services\Translator
{
}
```

0 comments on commit 595ea0f

Please sign in to comment.