@@ -31,7 +31,7 @@ |
||
31 | 31 | public function __construct(array $specifications, RequestInterface $request) |
32 | 32 | { |
33 | 33 | foreach ($specifications as $specification) { |
34 | - if (! $specification instanceof RouteMatchSpecificationInterface) { |
|
34 | + if ( ! $specification instanceof RouteMatchSpecificationInterface) { |
|
35 | 35 | throw new InvalidEntityException( |
36 | 36 | $specification, |
37 | 37 | 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' |
@@ -15,29 +15,29 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class MultiRouteSpecification extends RouteMatchSpecification |
17 | 17 | { |
18 | - /** |
|
19 | - * @var RouteMatchSpecificationInterface[] $specifications |
|
20 | - */ |
|
21 | - protected $specifications; |
|
18 | + /** |
|
19 | + * @var RouteMatchSpecificationInterface[] $specifications |
|
20 | + */ |
|
21 | + protected $specifications; |
|
22 | 22 | |
23 | - /** |
|
24 | - * MultiRouteSpecification constructor. |
|
25 | - * |
|
26 | - * @param RouteMatchSpecificationInterface[] $specifications |
|
27 | - * @param RequestInterface $request |
|
28 | - * @throws InvalidEntityException |
|
29 | - */ |
|
30 | - public function __construct(array $specifications, RequestInterface $request) |
|
31 | - { |
|
32 | - foreach ($specifications as $specification) { |
|
33 | - if (! $specification instanceof RouteMatchSpecificationInterface) { |
|
34 | - throw new InvalidEntityException( |
|
35 | - $specification, |
|
36 | - 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' |
|
37 | - ); |
|
38 | - } |
|
39 | - } |
|
40 | - $this->specifications = $specifications; |
|
41 | - parent::__construct($request); |
|
42 | - } |
|
23 | + /** |
|
24 | + * MultiRouteSpecification constructor. |
|
25 | + * |
|
26 | + * @param RouteMatchSpecificationInterface[] $specifications |
|
27 | + * @param RequestInterface $request |
|
28 | + * @throws InvalidEntityException |
|
29 | + */ |
|
30 | + public function __construct(array $specifications, RequestInterface $request) |
|
31 | + { |
|
32 | + foreach ($specifications as $specification) { |
|
33 | + if (! $specification instanceof RouteMatchSpecificationInterface) { |
|
34 | + throw new InvalidEntityException( |
|
35 | + $specification, |
|
36 | + 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' |
|
37 | + ); |
|
38 | + } |
|
39 | + } |
|
40 | + $this->specifications = $specifications; |
|
41 | + parent::__construct($request); |
|
42 | + } |
|
43 | 43 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | { |
116 | 116 | /** @var RouteMatchSpecificationInterface $specification */ |
117 | 117 | $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
118 | - if (! $specification instanceof $routeMatchSpecificationFqcn) { |
|
118 | + if ( ! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | 119 | throw new InvalidClassException($routeMatchSpecificationFqcn); |
120 | 120 | } |
121 | 121 | return $specification->isMatchingRoute(); |
@@ -25,122 +25,122 @@ |
||
25 | 25 | */ |
26 | 26 | class RouteMatchSpecificationManager |
27 | 27 | { |
28 | - /** |
|
29 | - * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | - */ |
|
31 | - private $specifications; |
|
28 | + /** |
|
29 | + * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | + */ |
|
31 | + private $specifications; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | - */ |
|
36 | - private $specifications_factory; |
|
33 | + /** |
|
34 | + * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | + */ |
|
36 | + private $specifications_factory; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * RouteMatchSpecificationManager constructor. |
|
41 | - * |
|
42 | - * @param RouteMatchSpecificationCollection $specifications |
|
43 | - * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | - */ |
|
45 | - public function __construct( |
|
46 | - RouteMatchSpecificationCollection $specifications, |
|
47 | - RouteMatchSpecificationFactory $specifications_factory |
|
48 | - ) { |
|
49 | - $this->specifications = $specifications; |
|
50 | - $this->specifications_factory = $specifications_factory; |
|
51 | - add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | - } |
|
39 | + /** |
|
40 | + * RouteMatchSpecificationManager constructor. |
|
41 | + * |
|
42 | + * @param RouteMatchSpecificationCollection $specifications |
|
43 | + * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | + */ |
|
45 | + public function __construct( |
|
46 | + RouteMatchSpecificationCollection $specifications, |
|
47 | + RouteMatchSpecificationFactory $specifications_factory |
|
48 | + ) { |
|
49 | + $this->specifications = $specifications; |
|
50 | + $this->specifications_factory = $specifications_factory; |
|
51 | + add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Perform any early setup required for block editors to functions |
|
57 | - * |
|
58 | - * @return void |
|
59 | - * @throws CollectionLoaderException |
|
60 | - * @throws CollectionDetailsException |
|
61 | - */ |
|
62 | - public function initialize() |
|
63 | - { |
|
64 | - $this->populateSpecificationCollection(); |
|
65 | - } |
|
55 | + /** |
|
56 | + * Perform any early setup required for block editors to functions |
|
57 | + * |
|
58 | + * @return void |
|
59 | + * @throws CollectionLoaderException |
|
60 | + * @throws CollectionDetailsException |
|
61 | + */ |
|
62 | + public function initialize() |
|
63 | + { |
|
64 | + $this->populateSpecificationCollection(); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | - * @throws CollectionLoaderException |
|
71 | - * @throws CollectionDetailsException |
|
72 | - * @since 4.9.71.p |
|
73 | - */ |
|
74 | - private function populateSpecificationCollection() |
|
75 | - { |
|
76 | - $loader = new CollectionLoader( |
|
77 | - new CollectionDetails( |
|
78 | - // collection name |
|
79 | - RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | - // collection interface |
|
81 | - 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface', |
|
82 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | - apply_filters( |
|
84 | - 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | - array( |
|
86 | - 'EventEspresso\core\domain\entities\routing\specifications\admin', |
|
87 | - 'EventEspresso\core\domain\entities\routing\specifications\frontend', |
|
88 | - ) |
|
89 | - ), |
|
90 | - // filepaths to classes to add |
|
91 | - array(), |
|
92 | - // file mask to use if parsing folder for files to add |
|
93 | - '', |
|
94 | - // what to use as identifier for collection entities |
|
95 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | - CollectionDetails::ID_CLASS_NAME |
|
97 | - ), |
|
98 | - $this->specifications, |
|
99 | - null, |
|
100 | - $this->specifications_factory |
|
101 | - ); |
|
102 | - return $loader->getCollection(); |
|
103 | - } |
|
68 | + /** |
|
69 | + * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | + * @throws CollectionLoaderException |
|
71 | + * @throws CollectionDetailsException |
|
72 | + * @since 4.9.71.p |
|
73 | + */ |
|
74 | + private function populateSpecificationCollection() |
|
75 | + { |
|
76 | + $loader = new CollectionLoader( |
|
77 | + new CollectionDetails( |
|
78 | + // collection name |
|
79 | + RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | + // collection interface |
|
81 | + 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface', |
|
82 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | + apply_filters( |
|
84 | + 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | + array( |
|
86 | + 'EventEspresso\core\domain\entities\routing\specifications\admin', |
|
87 | + 'EventEspresso\core\domain\entities\routing\specifications\frontend', |
|
88 | + ) |
|
89 | + ), |
|
90 | + // filepaths to classes to add |
|
91 | + array(), |
|
92 | + // file mask to use if parsing folder for files to add |
|
93 | + '', |
|
94 | + // what to use as identifier for collection entities |
|
95 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | + CollectionDetails::ID_CLASS_NAME |
|
97 | + ), |
|
98 | + $this->specifications, |
|
99 | + null, |
|
100 | + $this->specifications_factory |
|
101 | + ); |
|
102 | + return $loader->getCollection(); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | - * |
|
109 | - * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | - * @return bool |
|
111 | - * @throws InvalidClassException |
|
112 | - * @since 4.9.71.p |
|
113 | - */ |
|
114 | - public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn) |
|
115 | - { |
|
116 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | - $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | - if (! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | - throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | - } |
|
121 | - return $specification->isMatchingRoute(); |
|
122 | - } |
|
106 | + /** |
|
107 | + * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | + * |
|
109 | + * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | + * @return bool |
|
111 | + * @throws InvalidClassException |
|
112 | + * @since 4.9.71.p |
|
113 | + */ |
|
114 | + public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn) |
|
115 | + { |
|
116 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | + $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | + if (! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | + throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | + } |
|
121 | + return $specification->isMatchingRoute(); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Handy method for development that returns |
|
127 | - * a list of existing RouteMatchSpecification classes |
|
128 | - * matching the current request that can be used to identify it. |
|
129 | - * If no matches are returned (or nothing acceptable) |
|
130 | - * then create a new one that better matches your requirements. |
|
131 | - * |
|
132 | - * @return array |
|
133 | - * @since 4.9.71.p |
|
134 | - */ |
|
135 | - public function findRouteMatchSpecificationsMatchingCurrentRequest() |
|
136 | - { |
|
137 | - $matches = array(); |
|
138 | - foreach ($this->specifications as $specification) { |
|
139 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | - if ($specification->isMatchingRoute()) { |
|
141 | - $matches[] = get_class($specification); |
|
142 | - } |
|
143 | - } |
|
144 | - return $matches; |
|
145 | - } |
|
125 | + /** |
|
126 | + * Handy method for development that returns |
|
127 | + * a list of existing RouteMatchSpecification classes |
|
128 | + * matching the current request that can be used to identify it. |
|
129 | + * If no matches are returned (or nothing acceptable) |
|
130 | + * then create a new one that better matches your requirements. |
|
131 | + * |
|
132 | + * @return array |
|
133 | + * @since 4.9.71.p |
|
134 | + */ |
|
135 | + public function findRouteMatchSpecificationsMatchingCurrentRequest() |
|
136 | + { |
|
137 | + $matches = array(); |
|
138 | + foreach ($this->specifications as $specification) { |
|
139 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | + if ($specification->isMatchingRoute()) { |
|
141 | + $matches[] = get_class($specification); |
|
142 | + } |
|
143 | + } |
|
144 | + return $matches; |
|
145 | + } |
|
146 | 146 | } |
@@ -19,22 +19,22 @@ |
||
19 | 19 | */ |
20 | 20 | class WordPressPostsEditor extends MatchAnyRouteSpecification |
21 | 21 | { |
22 | - /** |
|
23 | - * WordPressPostsEditor constructor. |
|
24 | - * |
|
25 | - * @param WordPressPostsEditorEdit $edit_post_route_match |
|
26 | - * @param WordPressPostsEditorAddNew $create_post_route_match |
|
27 | - * @param RequestInterface $request |
|
28 | - * @throws InvalidEntityException |
|
29 | - */ |
|
30 | - public function __construct( |
|
31 | - WordPressPostsEditorEdit $edit_post_route_match, |
|
32 | - WordPressPostsEditorAddNew $create_post_route_match, |
|
33 | - RequestInterface $request |
|
34 | - ) { |
|
35 | - parent::__construct( |
|
36 | - array($edit_post_route_match, $create_post_route_match), |
|
37 | - $request |
|
38 | - ); |
|
39 | - } |
|
22 | + /** |
|
23 | + * WordPressPostsEditor constructor. |
|
24 | + * |
|
25 | + * @param WordPressPostsEditorEdit $edit_post_route_match |
|
26 | + * @param WordPressPostsEditorAddNew $create_post_route_match |
|
27 | + * @param RequestInterface $request |
|
28 | + * @throws InvalidEntityException |
|
29 | + */ |
|
30 | + public function __construct( |
|
31 | + WordPressPostsEditorEdit $edit_post_route_match, |
|
32 | + WordPressPostsEditorAddNew $create_post_route_match, |
|
33 | + RequestInterface $request |
|
34 | + ) { |
|
35 | + parent::__construct( |
|
36 | + array($edit_post_route_match, $create_post_route_match), |
|
37 | + $request |
|
38 | + ); |
|
39 | + } |
|
40 | 40 | } |
@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoEventEditorEdit extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->isAdmin() |
|
29 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | - && $this->request->getRequestParam('action', 'edit') === 'edit'; |
|
31 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->isAdmin() |
|
29 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | + && $this->request->getRequestParam('action', 'edit') === 'edit'; |
|
31 | + } |
|
32 | 32 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoEventsListTable extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
29 | - && $this->request->getRequestParam('action', 'default') === 'default'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
29 | + && $this->request->getRequestParam('action', 'default') === 'default'; |
|
30 | + } |
|
31 | 31 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoVenueEditorAddNew extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | - && $this->request->getRequestParam('action') === 'create_new'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | + && $this->request->getRequestParam('action') === 'create_new'; |
|
30 | + } |
|
31 | 31 | } |
@@ -14,17 +14,17 @@ |
||
14 | 14 | */ |
15 | 15 | class WordPressPostsListTable extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'edit.php' |
|
28 | - && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
29 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'edit.php' |
|
28 | + && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
29 | + } |
|
30 | 30 | } |
@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoEventEditorAddNew extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->isAdmin() |
|
29 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | - && $this->request->getRequestParam('action') === 'create_new'; |
|
31 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->isAdmin() |
|
29 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
30 | + && $this->request->getRequestParam('action') === 'create_new'; |
|
31 | + } |
|
32 | 32 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoVenueEditorEdit extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | - && $this->request->getRequestParam('action') === 'edit'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_venues' |
|
29 | + && $this->request->getRequestParam('action') === 'edit'; |
|
30 | + } |
|
31 | 31 | } |