PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.2
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.2
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 2 weeks ago Constants 5 days ago Contracts 5 days ago Database 5 days ago Discovery 5 days ago Exceptions 2 weeks ago Filesystem 2 weeks ago Http 5 days ago Managers 5 days ago Middlewares 1 month ago Polyfill 1 month ago Routing 2 weeks ago Supports 2 weeks ago Validation 1 week ago View 2 weeks ago Wordpress 5 days ago ApiExceptionHandler.php 1 month ago Application.php 5 days ago Container.php 1 month ago CoreServiceProvider.php 2 weeks ago DTO.php 1 month ago Facade.php 1 month ago Listener.php 1 month ago Resource.php 2 weeks ago Route.php 2 weeks ago Sanitizer.php 2 weeks ago ServiceProvider.php 1 month ago SiteExceptionHandler.php 2 weeks ago helpers.php 2 weeks ago
CoreServiceProvider.php
144 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\EventManager;
23 use Kirki\Framework\Managers\LogManager;
24 use Kirki\Framework\Managers\PolicyManager;
25 use Kirki\Framework\ServiceProvider;
26 use Kirki\Framework\Http\Response;
27 use Kirki\Framework\Supports\MessagesBag;
28 use Kirki\Framework\Supports\Somoy;
29 use Kirki\Framework\View\TemplateEngine;
30 use Kirki\Framework\View\ViewContext;
31 class CoreServiceProvider extends ServiceProvider
32 {
33 /**
34 * Register the hooks to the application.
35 *
36 * @return void
37 *
38 * @since 1.0.0
39 */
40 public function register()
41 {
42 $this->register_database_services();
43 $this->register_discoveries();
44 $this->register_managers();
45 $this->register_migrations();
46 $this->register_messages();
47 $this->app->singleton(Response::class);
48 $this->app->singleton(TemplateEngine::class);
49 $this->app->singleton(ViewContext::class);
50 if (\class_exists(\Faker\Factory::class)) {
51 $this->app->singleton(\Faker\Factory::class, function () {
52 return \Faker\Factory::create();
53 });
54 }
55 }
56 /**
57 * Boot the service provider.
58 *
59 * @return void
60 *
61 * @since 1.0.0
62 */
63 public function boot()
64 {
65 $this->app->make(PolicyDiscovery::class)->discover()->cache();
66 $this->app->make(ListenerDiscovery::class)->discover()->cache();
67 }
68 /**
69 * Register the messages.
70 *
71 * @return void
72 *
73 * @since 1.0.0
74 */
75 protected function register_messages()
76 {
77 $this->app->singleton(MessagesBag::class, function () {
78 return new MessagesBag();
79 });
80 }
81 /**
82 * Register the managers.
83 *
84 * @return void
85 *
86 * @since 1.0.0
87 */
88 protected function register_managers()
89 {
90 $this->app->singleton(DatabaseManager::class);
91 $this->app->singleton(SchemaManager::class);
92 $this->app->singleton(LogManager::class);
93 $this->app->singleton(EventManager::class);
94 $this->app->singleton(PolicyManager::class);
95 $this->app->bind(SomoyInterface::class, function () {
96 return new Somoy();
97 });
98 $this->app->singleton(CommandManager::class);
99 }
100 /**
101 * Register the discoveries.
102 *
103 * @return void
104 *
105 * @since 1.0.0
106 */
107 protected function register_discoveries()
108 {
109 $this->app->singleton(ListenerDiscovery::class);
110 $this->app->singleton(PolicyDiscovery::class);
111 }
112 /**
113 * Register the database singletons.
114 *
115 * @return void
116 *
117 * @since 1.0.0
118 */
119 protected function register_database_services()
120 {
121 $this->app->singleton(Connection::class);
122 $this->app->singleton(Migrator::class);
123 }
124 /**
125 * Register the migrations tags.
126 *
127 * @return void
128 *
129 * @since 1.0.0
130 */
131 protected function register_migrations()
132 {
133 $migrations_path = $this->app->config_path('migrations.php');
134 if (!\file_exists($migrations_path)) {
135 return;
136 }
137 $migrations = (include $migrations_path);
138 if (empty($migrations)) {
139 return;
140 }
141 $this->app->tag($migrations, 'app.migrations');
142 }
143 }
144