1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\route_match; |
4
|
|
|
|
5
|
|
|
use EventEspresso\core\domain\entities\route_match\RouteMatchSpecification; |
6
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
7
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
8
|
|
|
use EventEspresso\core\services\factory\FactoryWithDependencyResolver; |
9
|
|
|
use EventEspresso\core\services\loaders\LoaderFactory; |
10
|
|
|
use EventEspresso\core\services\loaders\LoaderInterface; |
11
|
|
|
use InvalidArgumentException; |
12
|
|
|
use ReflectionException; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class RouteMatchSpecificationFactory |
16
|
|
|
* Factory for generating RouteMatchSpecification classes. |
17
|
|
|
* Will automatically resolve dependencies using the |
18
|
|
|
* RouteMatchSpecificationDependencyResolver |
19
|
|
|
* |
20
|
|
|
* @package EventEspresso\core\services\route_match |
21
|
|
|
* @author Brent Christensen |
22
|
|
|
* @since $VID:$ |
23
|
|
|
*/ |
24
|
|
|
class RouteMatchSpecificationFactory extends FactoryWithDependencyResolver |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* RouteMatchSpecificationFactory constructor |
29
|
|
|
* |
30
|
|
|
* @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
31
|
|
|
* @param LoaderInterface $loader |
32
|
|
|
*/ |
33
|
|
|
public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
34
|
|
|
{ |
35
|
|
|
parent::__construct($dependency_resolver, $loader); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $fqcn |
40
|
|
|
* @return RouteMatchSpecification |
41
|
|
|
* @throws InvalidDataTypeException |
42
|
|
|
* @throws ReflectionException |
43
|
|
|
* @since $VID:$ |
44
|
|
|
*/ |
45
|
|
|
public function createNewRouteMatchSpecification($fqcn) |
46
|
|
|
{ |
47
|
|
|
$this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
48
|
|
|
return $this->loader()->getShared($fqcn); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param $fqcn |
54
|
|
|
* @return RouteMatchSpecification |
55
|
|
|
* @throws InvalidArgumentException |
56
|
|
|
* @throws InvalidDataTypeException |
57
|
|
|
* @throws InvalidInterfaceException |
58
|
|
|
* @throws ReflectionException |
59
|
|
|
* @since $VID:$ |
60
|
|
|
*/ |
61
|
|
|
public static function create($fqcn) |
62
|
|
|
{ |
63
|
|
|
/** @var RouteMatchSpecificationFactory $specification_factory */ |
64
|
|
|
$specification_factory = LoaderFactory::getLoader()->getShared( |
65
|
|
|
'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' |
66
|
|
|
); |
67
|
|
|
return $specification_factory->createNewRouteMatchSpecification($fqcn); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|