@@ -13,148 +13,148 @@ |
||
13 | 13 | * @package Intraxia\Jaxion |
14 | 14 | */ |
15 | 15 | class Application extends Container implements ApplicationContract { |
16 | - /** |
|
17 | - * Define plugin version on Application. |
|
18 | - */ |
|
19 | - const VERSION = ''; |
|
20 | - |
|
21 | - /** |
|
22 | - * Singleton instance of the Application object |
|
23 | - * |
|
24 | - * @var Application |
|
25 | - */ |
|
26 | - protected static $instance = null; |
|
27 | - |
|
28 | - /** |
|
29 | - * Instantiates a new Application container. |
|
30 | - * |
|
31 | - * The Application constructor enforces the presence of of a single instance |
|
32 | - * of the Application. If an instance already exists, an Exception will be thrown. |
|
33 | - * |
|
34 | - * @param string $file |
|
35 | - * @param array $providers |
|
36 | - * |
|
37 | - * @throws ApplicationAlreadyBootedException |
|
38 | - */ |
|
39 | - public function __construct( $file, array $providers = array() ) { |
|
40 | - if ( null !== static::$instance ) { |
|
41 | - throw new ApplicationAlreadyBootedException; |
|
42 | - } |
|
43 | - |
|
44 | - static::$instance = $this; |
|
45 | - |
|
46 | - $this->register_constants( $file ); |
|
47 | - $this->register_core_services(); |
|
48 | - $this->load_i18n(); |
|
49 | - |
|
50 | - register_activation_hook( $file, array( $this, 'activate' ) ); |
|
51 | - register_deactivation_hook( $file, array( $this, 'deactivate' ) ); |
|
52 | - |
|
53 | - parent::__construct( $providers ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * {@inheritDoc} |
|
58 | - * |
|
59 | - * @throws UnexpectedValueException |
|
60 | - */ |
|
61 | - public function boot() { |
|
62 | - $loader = $this->fetch( 'loader' ); |
|
63 | - |
|
64 | - if ( ! $loader instanceof LoaderContract ) { |
|
65 | - throw new UnexpectedValueException; |
|
66 | - } |
|
67 | - |
|
68 | - foreach ( $this as $alias => $value ) { |
|
69 | - if ( $value instanceof HasActions ) { |
|
70 | - $loader->register_actions( $value ); |
|
71 | - } |
|
72 | - |
|
73 | - if ( $value instanceof HasFilters ) { |
|
74 | - $loader->register_filters( $value ); |
|
75 | - } |
|
76 | - |
|
77 | - if ( $value instanceof HasShortcode ) { |
|
78 | - $loader->register_shortcode( $value ); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - add_action( 'plugins_loaded', array( $loader, 'run' ) ); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * {@inheritdoc} |
|
87 | - * |
|
88 | - * @codeCoverageIgnore |
|
89 | - */ |
|
90 | - public function activate() { |
|
91 | - // no-op |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * {@inheritdoc} |
|
96 | - * |
|
97 | - * @codeCoverageIgnore |
|
98 | - */ |
|
99 | - public function deactivate() { |
|
100 | - // no-op |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * {@inheritDoc} |
|
105 | - * |
|
106 | - * @return Application |
|
107 | - * @throws ApplicationNotBootedException |
|
108 | - */ |
|
109 | - public static function instance() { |
|
110 | - if ( null === static::$instance ) { |
|
111 | - throw new ApplicationNotBootedException; |
|
112 | - } |
|
113 | - |
|
114 | - return static::$instance; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * {@inheritDoc} |
|
119 | - */ |
|
120 | - public static function shutdown() { |
|
121 | - if ( null !== static::$instance ) { |
|
122 | - static::$instance = null; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Sets the plugin's url, path, and basename. |
|
128 | - * |
|
129 | - * @param string $file |
|
130 | - */ |
|
131 | - private function register_constants( $file ) { |
|
132 | - $this->share( 'url', plugin_dir_url( $file ) ); |
|
133 | - $this->share( 'path', plugin_dir_path( $file ) ); |
|
134 | - $this->share( 'basename', $basename = plugin_basename( $file ) ); |
|
135 | - $this->share( 'slug', dirname( $basename ) ); |
|
136 | - $this->share( 'version', static::VERSION ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Registers the built-in services with the Application container. |
|
141 | - */ |
|
142 | - private function register_core_services() { |
|
143 | - $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { |
|
144 | - return new Loader( $app ); |
|
145 | - } ); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Load's the plugin's translation files. |
|
150 | - */ |
|
151 | - private function load_i18n() { |
|
152 | - add_action( 'init', function(){ |
|
153 | - load_plugin_textdomain( |
|
154 | - $this->fetch( 'basename' ), |
|
155 | - false, |
|
156 | - basename( $this->fetch( 'path' ) ) . '/languages/' |
|
157 | - ); |
|
158 | - }); |
|
159 | - } |
|
16 | + /** |
|
17 | + * Define plugin version on Application. |
|
18 | + */ |
|
19 | + const VERSION = ''; |
|
20 | + |
|
21 | + /** |
|
22 | + * Singleton instance of the Application object |
|
23 | + * |
|
24 | + * @var Application |
|
25 | + */ |
|
26 | + protected static $instance = null; |
|
27 | + |
|
28 | + /** |
|
29 | + * Instantiates a new Application container. |
|
30 | + * |
|
31 | + * The Application constructor enforces the presence of of a single instance |
|
32 | + * of the Application. If an instance already exists, an Exception will be thrown. |
|
33 | + * |
|
34 | + * @param string $file |
|
35 | + * @param array $providers |
|
36 | + * |
|
37 | + * @throws ApplicationAlreadyBootedException |
|
38 | + */ |
|
39 | + public function __construct( $file, array $providers = array() ) { |
|
40 | + if ( null !== static::$instance ) { |
|
41 | + throw new ApplicationAlreadyBootedException; |
|
42 | + } |
|
43 | + |
|
44 | + static::$instance = $this; |
|
45 | + |
|
46 | + $this->register_constants( $file ); |
|
47 | + $this->register_core_services(); |
|
48 | + $this->load_i18n(); |
|
49 | + |
|
50 | + register_activation_hook( $file, array( $this, 'activate' ) ); |
|
51 | + register_deactivation_hook( $file, array( $this, 'deactivate' ) ); |
|
52 | + |
|
53 | + parent::__construct( $providers ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * {@inheritDoc} |
|
58 | + * |
|
59 | + * @throws UnexpectedValueException |
|
60 | + */ |
|
61 | + public function boot() { |
|
62 | + $loader = $this->fetch( 'loader' ); |
|
63 | + |
|
64 | + if ( ! $loader instanceof LoaderContract ) { |
|
65 | + throw new UnexpectedValueException; |
|
66 | + } |
|
67 | + |
|
68 | + foreach ( $this as $alias => $value ) { |
|
69 | + if ( $value instanceof HasActions ) { |
|
70 | + $loader->register_actions( $value ); |
|
71 | + } |
|
72 | + |
|
73 | + if ( $value instanceof HasFilters ) { |
|
74 | + $loader->register_filters( $value ); |
|
75 | + } |
|
76 | + |
|
77 | + if ( $value instanceof HasShortcode ) { |
|
78 | + $loader->register_shortcode( $value ); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + add_action( 'plugins_loaded', array( $loader, 'run' ) ); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * {@inheritdoc} |
|
87 | + * |
|
88 | + * @codeCoverageIgnore |
|
89 | + */ |
|
90 | + public function activate() { |
|
91 | + // no-op |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * {@inheritdoc} |
|
96 | + * |
|
97 | + * @codeCoverageIgnore |
|
98 | + */ |
|
99 | + public function deactivate() { |
|
100 | + // no-op |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * {@inheritDoc} |
|
105 | + * |
|
106 | + * @return Application |
|
107 | + * @throws ApplicationNotBootedException |
|
108 | + */ |
|
109 | + public static function instance() { |
|
110 | + if ( null === static::$instance ) { |
|
111 | + throw new ApplicationNotBootedException; |
|
112 | + } |
|
113 | + |
|
114 | + return static::$instance; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * {@inheritDoc} |
|
119 | + */ |
|
120 | + public static function shutdown() { |
|
121 | + if ( null !== static::$instance ) { |
|
122 | + static::$instance = null; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Sets the plugin's url, path, and basename. |
|
128 | + * |
|
129 | + * @param string $file |
|
130 | + */ |
|
131 | + private function register_constants( $file ) { |
|
132 | + $this->share( 'url', plugin_dir_url( $file ) ); |
|
133 | + $this->share( 'path', plugin_dir_path( $file ) ); |
|
134 | + $this->share( 'basename', $basename = plugin_basename( $file ) ); |
|
135 | + $this->share( 'slug', dirname( $basename ) ); |
|
136 | + $this->share( 'version', static::VERSION ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Registers the built-in services with the Application container. |
|
141 | + */ |
|
142 | + private function register_core_services() { |
|
143 | + $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { |
|
144 | + return new Loader( $app ); |
|
145 | + } ); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Load's the plugin's translation files. |
|
150 | + */ |
|
151 | + private function load_i18n() { |
|
152 | + add_action( 'init', function(){ |
|
153 | + load_plugin_textdomain( |
|
154 | + $this->fetch( 'basename' ), |
|
155 | + false, |
|
156 | + basename( $this->fetch( 'path' ) ) . '/languages/' |
|
157 | + ); |
|
158 | + }); |
|
159 | + } |
|
160 | 160 | } |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @throws ApplicationAlreadyBootedException |
38 | 38 | */ |
39 | - public function __construct( $file, array $providers = array() ) { |
|
40 | - if ( null !== static::$instance ) { |
|
39 | + public function __construct($file, array $providers = array()) { |
|
40 | + if (null !== static::$instance) { |
|
41 | 41 | throw new ApplicationAlreadyBootedException; |
42 | 42 | } |
43 | 43 | |
44 | 44 | static::$instance = $this; |
45 | 45 | |
46 | - $this->register_constants( $file ); |
|
46 | + $this->register_constants($file); |
|
47 | 47 | $this->register_core_services(); |
48 | 48 | $this->load_i18n(); |
49 | 49 | |
50 | - register_activation_hook( $file, array( $this, 'activate' ) ); |
|
51 | - register_deactivation_hook( $file, array( $this, 'deactivate' ) ); |
|
50 | + register_activation_hook($file, array($this, 'activate')); |
|
51 | + register_deactivation_hook($file, array($this, 'deactivate')); |
|
52 | 52 | |
53 | - parent::__construct( $providers ); |
|
53 | + parent::__construct($providers); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,27 +59,27 @@ discard block |
||
59 | 59 | * @throws UnexpectedValueException |
60 | 60 | */ |
61 | 61 | public function boot() { |
62 | - $loader = $this->fetch( 'loader' ); |
|
62 | + $loader = $this->fetch('loader'); |
|
63 | 63 | |
64 | - if ( ! $loader instanceof LoaderContract ) { |
|
64 | + if (!$loader instanceof LoaderContract) { |
|
65 | 65 | throw new UnexpectedValueException; |
66 | 66 | } |
67 | 67 | |
68 | - foreach ( $this as $alias => $value ) { |
|
69 | - if ( $value instanceof HasActions ) { |
|
70 | - $loader->register_actions( $value ); |
|
68 | + foreach ($this as $alias => $value) { |
|
69 | + if ($value instanceof HasActions) { |
|
70 | + $loader->register_actions($value); |
|
71 | 71 | } |
72 | 72 | |
73 | - if ( $value instanceof HasFilters ) { |
|
74 | - $loader->register_filters( $value ); |
|
73 | + if ($value instanceof HasFilters) { |
|
74 | + $loader->register_filters($value); |
|
75 | 75 | } |
76 | 76 | |
77 | - if ( $value instanceof HasShortcode ) { |
|
78 | - $loader->register_shortcode( $value ); |
|
77 | + if ($value instanceof HasShortcode) { |
|
78 | + $loader->register_shortcode($value); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - add_action( 'plugins_loaded', array( $loader, 'run' ) ); |
|
82 | + add_action('plugins_loaded', array($loader, 'run')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @throws ApplicationNotBootedException |
108 | 108 | */ |
109 | 109 | public static function instance() { |
110 | - if ( null === static::$instance ) { |
|
110 | + if (null === static::$instance) { |
|
111 | 111 | throw new ApplicationNotBootedException; |
112 | 112 | } |
113 | 113 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * {@inheritDoc} |
119 | 119 | */ |
120 | 120 | public static function shutdown() { |
121 | - if ( null !== static::$instance ) { |
|
121 | + if (null !== static::$instance) { |
|
122 | 122 | static::$instance = null; |
123 | 123 | } |
124 | 124 | } |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param string $file |
130 | 130 | */ |
131 | - private function register_constants( $file ) { |
|
132 | - $this->share( 'url', plugin_dir_url( $file ) ); |
|
133 | - $this->share( 'path', plugin_dir_path( $file ) ); |
|
134 | - $this->share( 'basename', $basename = plugin_basename( $file ) ); |
|
135 | - $this->share( 'slug', dirname( $basename ) ); |
|
136 | - $this->share( 'version', static::VERSION ); |
|
131 | + private function register_constants($file) { |
|
132 | + $this->share('url', plugin_dir_url($file)); |
|
133 | + $this->share('path', plugin_dir_path($file)); |
|
134 | + $this->share('basename', $basename = plugin_basename($file)); |
|
135 | + $this->share('slug', dirname($basename)); |
|
136 | + $this->share('version', static::VERSION); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Registers the built-in services with the Application container. |
141 | 141 | */ |
142 | 142 | private function register_core_services() { |
143 | - $this->share( array( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ), function ( $app ) { |
|
144 | - return new Loader( $app ); |
|
143 | + $this->share(array('loader' => 'Intraxia\Jaxion\Contract\Core\Loader'), function($app) { |
|
144 | + return new Loader($app); |
|
145 | 145 | } ); |
146 | 146 | } |
147 | 147 | |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | * Load's the plugin's translation files. |
150 | 150 | */ |
151 | 151 | private function load_i18n() { |
152 | - add_action( 'init', function(){ |
|
152 | + add_action('init', function() { |
|
153 | 153 | load_plugin_textdomain( |
154 | - $this->fetch( 'basename' ), |
|
154 | + $this->fetch('basename'), |
|
155 | 155 | false, |
156 | - basename( $this->fetch( 'path' ) ) . '/languages/' |
|
156 | + basename($this->fetch('path')).'/languages/' |
|
157 | 157 | ); |
158 | 158 | }); |
159 | 159 | } |