1
|
|
|
<?php |
2
|
|
|
namespace Gvera\Helpers\entities; |
3
|
|
|
|
4
|
|
|
use Doctrine\Common\Cache\ApcCache; |
5
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
6
|
|
|
use Doctrine\Common\EventManager; |
7
|
|
|
use Doctrine\Common\Cache\RedisCache; |
8
|
|
|
use Doctrine\DBAL\DBALException; |
|
|
|
|
9
|
|
|
use Doctrine\DBAL\DriverManager; |
10
|
|
|
use Doctrine\DBAL\Exception; |
11
|
|
|
use Doctrine\ORM\Configuration; |
12
|
|
|
use Doctrine\ORM\EntityManager; |
13
|
|
|
use Doctrine\ORM\Exception\MissingMappingDriverImplementation; |
14
|
|
|
use Gvera\Helpers\config\Config; |
15
|
|
|
use function PHPUnit\Framework\isEmpty; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Entities Class Doc Comment |
19
|
|
|
* |
20
|
|
|
* @category Class |
21
|
|
|
* @package src/helpser/entities |
22
|
|
|
* @author Guido Vera |
23
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License |
24
|
|
|
* @link http://www.github.com/veraguido/gv |
25
|
|
|
* |
26
|
|
|
*/ |
27
|
|
|
class GvEntityManager extends EntityManager |
28
|
|
|
{ |
29
|
|
|
const PROXIES_PATH = __DIR__ . '/../../../var/proxies/'; |
30
|
|
|
const MODELS_PATH = __DIR__ . '/../../../src/Models/'; |
31
|
|
|
const SECONDARY_MODELS_PATH = __DIR__ . '/../../../vendor/gvera/core-entities/src/Models/'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param Config $config |
35
|
|
|
* @param string|null $modelsPaths |
36
|
|
|
* @param string|null $secondaryModelsPath |
37
|
|
|
* @throws Exception |
38
|
|
|
* @throws MissingMappingDriverImplementation |
39
|
|
|
*/ |
40
|
|
|
public function __construct(Config $config, $modelsPaths = null, string $secondaryModelsPath = null) |
41
|
|
|
{ |
42
|
|
|
|
43
|
|
|
$devMode = $config->getConfigItem('devmode'); |
44
|
|
|
$mysqlConfig = $config->getConfigItem('mysql'); |
45
|
|
|
$cache = new ArrayCache(); |
|
|
|
|
46
|
|
|
if (!$devMode) { |
47
|
|
|
$cache = new ApcCache(); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$primaryPath = $modelsPaths ?? self::MODELS_PATH; |
51
|
|
|
$secondaryPath = $secondaryModelsPath ?? self::SECONDARY_MODELS_PATH; |
52
|
|
|
|
53
|
|
|
$paths = [$primaryPath, $secondaryPath]; |
54
|
|
|
|
55
|
|
|
$doctrineConfig = new Configuration(); |
56
|
|
|
$doctrineConfig->setMetadataCacheImpl($cache); |
|
|
|
|
57
|
|
|
$driverImpl = $doctrineConfig->newDefaultAnnotationDriver($paths); |
|
|
|
|
58
|
|
|
$doctrineConfig->setMetadataDriverImpl($driverImpl); |
59
|
|
|
$doctrineConfig->setQueryCacheImpl($cache); |
|
|
|
|
60
|
|
|
$doctrineConfig->setProxyDir(self::PROXIES_PATH); |
61
|
|
|
$doctrineConfig->setProxyNamespace('Gvera\Models'); |
62
|
|
|
|
63
|
|
|
$doctrineConfig->setAutoGenerateProxyClasses($devMode); |
64
|
|
|
$dbParams = array( |
65
|
|
|
'driver' => $mysqlConfig['driver'], |
66
|
|
|
'host' => $mysqlConfig['host'], |
67
|
|
|
'user' => $mysqlConfig['username'], |
68
|
|
|
'password' => $mysqlConfig['password'], |
69
|
|
|
'dbname' => $mysqlConfig['db_name'] |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
$connection = DriverManager::getConnection($dbParams, $doctrineConfig); |
74
|
|
|
parent::__construct($connection, $doctrineConfig); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths