PHP code example of grifart / nette-scoped-di
1. Go to this page and download the library: Download grifart/nette-scoped-di library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grifart / nette-scoped-di example snippets
declare(strict_types=1);
namespace App\Infrastructure;
use Mangoweb\NetteDIScope\ScopeExtension;
use Nette\Configurator;
final class ModelExtension extends ScopeExtension
{
public static function getTagName(): string
{
// Every service marketed with an `exported` tag will be available in every *user* DI container
return 'exported';
}
protected function createInnerConfigurator(): Configurator // @phpstan-ignore-line
{
$configurator = parent::createInnerConfigurator();
$configurator->addConfig(__DIR__ . '/../container.neon'); // the configration entrypoint of the *model* container
$configurator->addConfig(__DIR__ . '/../../config/config.local.neon'); // parameters that are needed for the *model* container
$configurator->addStaticParameters([ // provide the %modelDir% parameter so the model is self-aware of where it lays
'modelDir' => __DIR__ . '/../'
]);
return $configurator;
}
}
namespace App\Model\Infrastructure\Email;
interface EmailSender {
function send(TheMessage $message): void;
}