/
StandardPackageProvider.php
48 lines (43 loc) · 1.27 KB
/
StandardPackageProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Concrete\Core\Database\EntityManager\Provider;
use Concrete\Core\Application\Application;
use Concrete\Core\Database\EntityManager\Driver\Driver;
use Concrete\Core\Package\Package;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
/**
* A simple, standard package provider; provide a Concrete\Core\Package\Package controller, and a path (or array of
* paths) to PHP entity classes. This uses the annotation driver.
* Class PackageProvider
*/
class StandardPackageProvider extends AbstractPackageProvider
{
/**
* @var array
*/
protected $locations = [];
/**
* Constructor
*
* @param Application $app
* @param Package $pkg
* @param array $locations
*/
public function __construct(Application $app, Package $pkg, $locations)
{
parent::__construct($app, $pkg);
$this->locations = $locations;
}
/**
* {@inheritDoc}
*/
public function getDrivers()
{
$drivers = [];
$reader = $this->getAnnotationReader();
foreach($this->locations as $path => $prefix) {
$drivers[] = new Driver(trim($prefix, '\\'),
new AnnotationDriver($reader, $this->pkg->getPackagePath() . '/' . $path));
}
return $drivers;
}
}