update readme
This commit is contained in:
parent
f054af35c3
commit
fed49011bd
88 changed files with 7546 additions and 176 deletions
32
app/src/Factory/DoctrineEm.php
Normal file
32
app/src/Factory/DoctrineEm.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace Lubian\NoFramework\Factory;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
|
||||
use Doctrine\ORM\Tools\Setup;
|
||||
use Lubian\NoFramework\Settings;
|
||||
|
||||
final class DoctrineEm
|
||||
{
|
||||
public function __construct(private Settings $settings){}
|
||||
public function create(): EntityManagerInterface
|
||||
{
|
||||
$config = Setup::createConfiguration($this->settings->doctrine['devMode']);
|
||||
|
||||
$config->setMetadataDriverImpl(
|
||||
new AttributeDriver(
|
||||
$this->settings->doctrine['metadataDirs']
|
||||
)
|
||||
);
|
||||
|
||||
return EntityManager::create(
|
||||
$this->settings->connection,
|
||||
$config,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -18,8 +18,9 @@ final class SettingsContainerProvider implements ContainerProvider
|
|||
$builder = new ContainerBuilder;
|
||||
$settings = $this->settingsProvider->getSettings();
|
||||
$dependencies = require $settings->dependenciesFile;
|
||||
$dependencies[Settings::class] = fn (): Settings => $settings;
|
||||
$dependencies[Settings::class] = $settings;
|
||||
$builder->addDefinitions($dependencies);
|
||||
// $builder->enableCompilation('/tmp');
|
||||
return $builder->build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue