Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/Business/Metadata/DriverMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@

use Doctrine\ORM\Configuration;
use Doctrine\ORM\ORMSetup;
use Micro\Plugin\Cache\Facade\CacheFacadeInterface;
use Micro\Plugin\Doctrine\Business\Locator\EntityFileConfigurationLocatorFactoryInterface;
use Micro\Plugin\Doctrine\Configuration\EntityManagerConfigurationInterface;
use Micro\Plugin\Doctrine\DoctrinePluginConfigurationInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

/**
* @author Stanislau Komar <head.trackingsoft@gmail.com>
Expand All @@ -25,7 +29,8 @@
{
public function __construct(
private EntityFileConfigurationLocatorFactoryInterface $entityFileConfigurationLocatorFactory,
private DoctrinePluginConfigurationInterface $pluginConfiguration
private DoctrinePluginConfigurationInterface $pluginConfiguration,
private ?CacheFacadeInterface $cacheFacade

Check failure on line 33 in src/Business/Metadata/DriverMetadataFactory.php

View workflow job for this annotation

GitHub Actions / Tests 8.2 deps highest

Property Micro\Plugin\Doctrine\Business\Metadata\DriverMetadataFactory::$cacheFacade has unknown class Micro\Plugin\Cache\Facade\CacheFacadeInterface as its type.

Check failure on line 33 in src/Business/Metadata/DriverMetadataFactory.php

View workflow job for this annotation

GitHub Actions / Tests 8.2 deps highest

Parameter $cacheFacade of method Micro\Plugin\Doctrine\Business\Metadata\DriverMetadataFactory::__construct() has invalid type Micro\Plugin\Cache\Facade\CacheFacadeInterface.
) {
}

Expand All @@ -41,4 +46,23 @@
$proxyDir
);
}

private function createCacheItem(EntityManagerConfigurationInterface $configuration): CacheItemPoolInterface

Check failure on line 50 in src/Business/Metadata/DriverMetadataFactory.php

View workflow job for this annotation

GitHub Actions / Tests 8.2 deps highest

Method Micro\Plugin\Doctrine\Business\Metadata\DriverMetadataFactory::createCacheItem() is unused.
{
$cacheItemPoolName = $configuration->getCacheItemPoolName();
if(!$cacheItemPoolName) {
return new ArrayAdapter();
}

if ($this->cacheFacade === null && $cacheItemPoolName) {

Check failure on line 57 in src/Business/Metadata/DriverMetadataFactory.php

View workflow job for this annotation

GitHub Actions / Tests 8.2 deps highest

Right side of && is always true.
throw new \RuntimeException(sprintf(
'Cache pool "%s" is configured for entity manager, but cache plugin is not enabled. Please, install `composer require micro/plugin-cache`',
$cacheItemPoolName
));
}



return $this->cacheFacade->getCachePsr16($configuration->getCacheItemPoolName());

Check failure on line 66 in src/Business/Metadata/DriverMetadataFactory.php

View workflow job for this annotation

GitHub Actions / Tests 8.2 deps highest

Call to method getCachePsr16() on an unknown class Micro\Plugin\Cache\Facade\CacheFacadeInterface.
}
}
14 changes: 14 additions & 0 deletions src/Configuration/EntityManagerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class EntityManagerConfiguration extends PluginRoutingKeyConfiguration implement
*/
public const CFG_PROXY_DIR = 'ORM_%s_PROXY_DIR';

/**
* Cache item pool name.
*
* Example `ORM_DEFAULT_CACHE_ITEM_POOL_NAME=default`
*
* @api
*/
public const CFG_CACHE_ITEM_POOL_NAME = 'ORM_%s_CACHE_ITEM_POOL_NAME';

/**
* @return string|null
*/
Expand Down Expand Up @@ -76,4 +85,9 @@ public function getAvailableDrivers(): array
{
return DriverManager::getAvailableDrivers();
}

public function getCacheItemPoolName(): ?string
{
return $this->get(self::CFG_CACHE_ITEM_POOL_NAME, null, false);
}
}
2 changes: 2 additions & 0 deletions src/Configuration/EntityManagerConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function getProxyDir(): ?string;
*/
public function getDriverName(): string;

public function getCacheItemPoolName(): ?string;

/**
* Implemented:
* 'pdo_mysql'
Expand Down
Loading