PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.4
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.4
6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / libraries / framework / CoreServiceProvider.php
kirki / libraries / framework Last commit date
Collections 1 month ago Concerns 1 month ago Console 4 weeks ago Constants 2 weeks ago Contracts 2 weeks ago Database 2 weeks ago Discovery 2 weeks ago Exceptions 4 weeks ago Filesystem 4 weeks ago Http 1 week ago Managers 1 week ago Middlewares 1 month ago Polyfill 1 month ago Routing 1 week ago Supports 1 week ago Validation 3 weeks ago View 4 weeks ago Wordpress 1 week ago ApiExceptionHandler.php 1 month ago Application.php 1 week ago Container.php 1 month ago CoreServiceProvider.php 1 week ago DTO.php 1 month ago Facade.php 1 month ago Listener.php 1 month ago Resource.php 4 weeks ago Route.php 1 week ago Sanitizer.php 4 weeks ago ServiceProvider.php 1 month ago SiteExceptionHandler.php 4 weeks ago helpers.php 1 week ago
CoreServiceProvider.php
146 lines
1 <?php
2
3 /**
4 * Registers the framework's essential services during application bootstrap.
5 * Binds database, schema, migration, discovery, and manager components into the container.
6 * Boots listener and policy discovery caching.
7 *
8 * @package Framework
9 * @since 1.0.0
10 */
11 namespace Kirki\Framework;
12
13 \defined('ABSPATH') || exit;
14 use Kirki\Framework\Console\CommandManager;
15 use Kirki\Framework\Database\Connection\Connection;
16 use Kirki\Framework\Database\Connection\DatabaseManager;
17 use Kirki\Framework\Database\Migrations\Migrator;
18 use Kirki\Framework\Database\Schema\SchemaManager;
19 use Kirki\Framework\Discovery\ListenerDiscovery;
20 use Kirki\Framework\Discovery\PolicyDiscovery;
21 use Kirki\Framework\Contracts\SomoyInterface;
22 use Kirki\Framework\Managers\CookieManager;
23 use Kirki\Framework\Managers\EventManager;
24 use Kirki\Framework\Managers\LogManager;
25 use Kirki\Framework\Managers\PolicyManager;
26 use Kirki\Framework\ServiceProvider;
27 use Kirki\Framework\Http\Response;
28 use Kirki\Framework\Supports\MessagesBag;
29 use Kirki\Framework\Supports\Somoy;
30 use Kirki\Framework\View\TemplateEngine;
31 use Kirki\Framework\View\ViewContext;
32 class CoreServiceProvider extends ServiceProvider
33 {
34 /**
35 * Register the hooks to the application.
36 *
37 * @return void
38 *
39 * @since 1.0.0
40 */
41 public function register()
42 {
43 $this->register_database_services();
44 $this->register_discoveries();
45 $this->register_managers();
46 $this->register_migrations();
47 $this->register_messages();
48 $this->app->singleton(Response::class);
49 $this->app->singleton(TemplateEngine::class);
50 $this->app->singleton(ViewContext::class);
51 if (\class_exists(\Faker\Factory::class)) {
52 $this->app->singleton(\Faker\Factory::class, function () {
53 return \Faker\Factory::create();
54 });
55 }
56 }
57 /**
58 * Boot the service provider.
59 *
60 * @return void
61 *
62 * @since 1.0.0
63 */
64 public function boot()
65 {
66 $this->app->make(PolicyDiscovery::class)->discover()->cache();
67 $this->app->make(ListenerDiscovery::class)->discover()->cache();
68 }
69 /**
70 * Register the messages.
71 *
72 * @return void
73 *
74 * @since 1.0.0
75 */
76 protected function register_messages()
77 {
78 $this->app->singleton(MessagesBag::class, function () {
79 return new MessagesBag();
80 });
81 }
82 /**
83 * Register the managers.
84 *
85 * @return void
86 *
87 * @since 1.0.0
88 */
89 protected function register_managers()
90 {
91 $this->app->singleton(DatabaseManager::class);
92 $this->app->singleton(SchemaManager::class);
93 $this->app->singleton(LogManager::class);
94 $this->app->singleton(EventManager::class);
95 $this->app->singleton(PolicyManager::class);
96 $this->app->singleton(CookieManager::class);
97 $this->app->bind(SomoyInterface::class, function () {
98 return new Somoy();
99 });
100 $this->app->singleton(CommandManager::class);
101 }
102 /**
103 * Register the discoveries.
104 *
105 * @return void
106 *
107 * @since 1.0.0
108 */
109 protected function register_discoveries()
110 {
111 $this->app->singleton(ListenerDiscovery::class);
112 $this->app->singleton(PolicyDiscovery::class);
113 }
114 /**
115 * Register the database singletons.
116 *
117 * @return void
118 *
119 * @since 1.0.0
120 */
121 protected function register_database_services()
122 {
123 $this->app->singleton(Connection::class);
124 $this->app->singleton(Migrator::class);
125 }
126 /**
127 * Register the migrations tags.
128 *
129 * @return void
130 *
131 * @since 1.0.0
132 */
133 protected function register_migrations()
134 {
135 $migrations_path = $this->app->config_path('migrations.php');
136 if (!\file_exists($migrations_path)) {
137 return;
138 }
139 $migrations = (include $migrations_path);
140 if (empty($migrations)) {
141 return;
142 }
143 $this->app->tag($migrations, 'app.migrations');
144 }
145 }
146