PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Database / Provider.php

Provider.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/Database/Provider.php

73 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Registers database related functionality in the container.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Database;
11
12 use SolidWP\Performance\Contracts\Service_Provider;
13 use SolidWP\Performance\Lock\Tables\Cache_Lock;
14 use SolidWP\Performance\Psr\Log\LoggerInterface;
15 use SolidWP\Performance\StellarWP\DB\Database\Exceptions\DatabaseQueryException;
16 use SolidWP\Performance\StellarWP\DB\DB;
17 use SolidWP\Performance\StellarWP\Schema\Config;
18 use SolidWP\Performance\StellarWP\Schema\Register;
19 use SolidWP\Performance\Timer\Tables\Timer_Table;
20
21 /**
22 * Registers database related functionality in the container.
23 *
24 * @package SolidWP\Performance
25 */
26 final class Provider extends Service_Provider {
27
28 public const SCHEMA_TABLES = 'solid_performance.database.schema_tables';
29
30 /**
31 * @inheritDoc
32 */
33 public function register(): void {
34 $this->register_schema();
35 }
36
37 /**
38 * Configure the stellarwp/schema library.
39 *
40 * @throws DatabaseQueryException If we failed to create or update the database tables.
41 *
42 * @return void
43 */
44 private function register_schema(): void {
45 Config::set_container( $this->container );
46 Config::set_db( DB::class );
47
48 // Add all schema tables to be registered here.
49 $this->container->setVar(
50 self::SCHEMA_TABLES,
51 [
52 Cache_Lock::class,
53 Timer_Table::class,
54 ]
55 );
56
57 try {
58 Register::tables( $this->container->getVar( self::SCHEMA_TABLES ) );
59 } catch ( DatabaseQueryException $e ) {
60 $this->container->get( LoggerInterface::class )->emergency(
61 'Unable to create or update database tables',
62 [
63 'query_errors' => $e->getQueryErrors(),
64 'query' => $e->getQuery(),
65 'exception' => $e,
66 ]
67 );
68
69 throw $e;
70 }
71 }
72 }
73