add chapter about data repositories, and start work on perfomance chapter
This commit is contained in:
parent
11172fb3d3
commit
7a0f368e00
165 changed files with 14028 additions and 2028 deletions
32
implementation/15-adding-content/src/Factory/DoctrineEm.php
Normal file
32
implementation/15-adding-content/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,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue