container = new Container(); $this->register_bindings(); } private function register_bindings(): void { $this->container->bind( ScansRepository::class, static fn (): ScansRepository => new ScansRepository() ); $this->container->bind( StatementsRepository::class, static fn (): StatementsRepository => new StatementsRepository() ); $this->container->bind( StatementGenerator::class, static fn (): StatementGenerator => new StatementGenerator() ); $this->container->bind( RestController::class, static fn ( Container $c ): RestController => new RestController( $c->get( ScansRepository::class ), $c->get( StatementsRepository::class ), $c->get( StatementGenerator::class ) ) ); } public function container(): Container { return $this->container; } public function boot(): void { if ( $this->booted ) { return; } $this->booted = true; // Admin surface. if ( is_admin() ) { $this->container->get( Menu::class )->register(); } // REST API. add_action( 'rest_api_init', function (): void { $this->container->get( RestController::class )->register_routes(); } ); do_action( 'wpag_booted', $this ); } }