PluginProbe
Depicter — Popup & Slider Builder / 1.2.0
Depicter — Popup & Slider Builder v1.2.0
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / htmlburger / wpemerge / src / Routing / RoutingServiceProvider.php

RoutingServiceProvider.php in Depicter — Popup & Slider Builder 1.2.0, at vendor/htmlburger/wpemerge/src/Routing/RoutingServiceProvider.php

107 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package WPEmerge
4 * @author Atanas Angelov <hi@atanas.dev>
5 * @copyright 2017-2019 Atanas Angelov
6 * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7 * @link https://wpemerge.com/
8 */
9
10 namespace WPEmerge\Routing;
11
12 use Pimple\Container;
13 use WPEmerge\Routing\Conditions\ConditionFactory;
14 use WPEmerge\ServiceProviders\ExtendsConfigTrait;
15 use WPEmerge\ServiceProviders\ServiceProviderInterface;
16
17 /**
18 * Provide routing dependencies
19 *
20 * @codeCoverageIgnore
21 */
22 class RoutingServiceProvider implements ServiceProviderInterface {
23 use ExtendsConfigTrait;
24
25 /**
26 * Key=>Class dictionary of condition types
27 *
28 * @var array<string, string>
29 */
30 protected static $condition_types = [
31 'url' => Conditions\UrlCondition::class,
32 'custom' => Conditions\CustomCondition::class,
33 'multiple' => Conditions\MultipleCondition::class,
34 'negate' => Conditions\NegateCondition::class,
35 'post_id' => Conditions\PostIdCondition::class,
36 'post_slug' => Conditions\PostSlugCondition::class,
37 'post_status' => Conditions\PostStatusCondition::class,
38 'post_template' => Conditions\PostTemplateCondition::class,
39 'post_type' => Conditions\PostTypeCondition::class,
40 'query_var' => Conditions\QueryVarCondition::class,
41 'ajax' => Conditions\AjaxCondition::class,
42 'admin' => Conditions\AdminCondition::class,
43 ];
44
45 /**
46 * {@inheritDoc}
47 */
48 public function register( $container ) {
49 $namespace = $container[ WPEMERGE_CONFIG_KEY ]['namespace'];
50
51 $this->extendConfig( $container, 'routes', [
52 'web' => [
53 'definitions' => '',
54 'attributes' => [
55 'middleware' => ['web'],
56 'namespace' => $namespace . 'Controllers\\Web\\',
57 'handler' => 'WPEmerge\\Controllers\\WordPressController@handle',
58 ],
59 ],
60 'admin' => [
61 'definitions' => '',
62 'attributes' => [
63 'middleware' => ['admin'],
64 'namespace' => $namespace . 'Controllers\\Admin\\',
65 ],
66 ],
67 'ajax' => [
68 'definitions' => '',
69 'attributes' => [
70 'middleware' => ['ajax'],
71 'namespace' => $namespace . 'Controllers\\Ajax\\',
72 ],
73 ],
74 ] );
75
76 /** @var Container $container */
77 $container[ WPEMERGE_ROUTING_CONDITION_TYPES_KEY ] = static::$condition_types;
78
79 $container[ WPEMERGE_ROUTING_ROUTER_KEY ] = function ( $c ) {
80 return new Router(
81 $c[ WPEMERGE_ROUTING_CONDITIONS_CONDITION_FACTORY_KEY ],
82 $c[ WPEMERGE_HELPERS_HANDLER_FACTORY_KEY ]
83 );
84 };
85
86 $container[ WPEMERGE_ROUTING_CONDITIONS_CONDITION_FACTORY_KEY ] = function ( $c ) {
87 return new ConditionFactory( $c[ WPEMERGE_ROUTING_CONDITION_TYPES_KEY ] );
88 };
89
90 $container[ WPEMERGE_ROUTING_ROUTE_BLUEPRINT_KEY ] = $container->factory( function ( $c ) {
91 return new RouteBlueprint( $c[ WPEMERGE_ROUTING_ROUTER_KEY ], $c[ WPEMERGE_VIEW_SERVICE_KEY ] );
92 } );
93
94 $app = $container[ WPEMERGE_APPLICATION_KEY ];
95 $app->alias( 'router', WPEMERGE_ROUTING_ROUTER_KEY );
96 $app->alias( 'route', WPEMERGE_ROUTING_ROUTE_BLUEPRINT_KEY );
97 $app->alias( 'routeUrl', WPEMERGE_ROUTING_ROUTER_KEY, 'getRouteUrl' );
98 }
99
100 /**
101 * {@inheritDoc}
102 */
103 public function bootstrap( $container ) {
104 // Nothing to bootstrap.
105 }
106 }
107