Commit b5cb7a7f authored by Avris's avatar Avris

improve separation of concerns, naming, structure

parent 3f4a6f11
#!/usr/bin/env php
<?php
use Avris\Micrus\App;
use Avris\Micrus\Bootstrap\App;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
......@@ -16,7 +16,7 @@ foreach (['', '/..', '/../..', '/../../..'] as $dir) {
}
/** @var EntityManager $em */
$em = (new App('cli'))->warmup()->get('orm')->getEntityManager();
$em = (new App('cli'))->getContainer()->get('orm')->getEntityManager();
$app = new Application('Doctrine');
$helperSet = $app->getHelperSet();
......
......@@ -3,10 +3,8 @@ namespace Avris\Micrus\Doctrine;
use Avris\Micrus\Console\ConsoleEvent;
use Avris\Micrus\Model\ORM;
use Avris\Micrus\Tool\Cache\CacheClearEvent;
use Avris\Micrus\Tool\Cache\CacheWarmupEvent;
use Avris\Micrus\Tool\Logger;
use Avris\Micrus\Tool\ParametersProvider;
use Avris\Micrus\Tool\Config\ParametersProvider;
use Doctrine\Common\Cache\ClearableCache;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\EntityManager;
......@@ -49,7 +47,7 @@ class Doctrine implements ORM, ParametersProvider
$this->entityManager = EntityManager::create($db, $config);
$warmup = $this->cacheWarmupEvent();
$warmup = $this->onCacheWarmup();
if ($warmup) {
$logger->notice($warmup);
}
......@@ -80,7 +78,7 @@ class Doctrine implements ORM, ParametersProvider
return $this->entityManager->getRepository($type)->findOneBy([$attribute => $value]);
}
public function cacheClearEvent()
public function onCacheClear()
{
$config = $this->entityManager->getConfiguration();
......@@ -97,7 +95,7 @@ class Doctrine implements ORM, ParametersProvider
}
}
public function cacheWarmupEvent()
public function onCacheWarmup()
{
if (file_exists($this->cacheDir)) {
return false;
......@@ -114,7 +112,7 @@ class Doctrine implements ORM, ParametersProvider
);
}
public function consoleEvent(ConsoleEvent $event)
public function onConsole(ConsoleEvent $event)
{
if (!$this->entityManager) {
return;
......
<?php
namespace Avris\Micrus\Doctrine;
use Avris\Micrus\Module;
use Avris\Micrus\Bootstrap\Module;
class DoctrineModule implements Module
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment