PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.3.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.3.2
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / includes / Providers / ClientServiceProvider.php

ClientServiceProvider.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.3.2, at includes/Providers/ClientServiceProvider.php

72 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 * Client Service Provider Class
4 *
5 * @package Easy_Invoice
6 * @subpackage Providers
7 */
8
9 namespace EasyInvoice\Providers;
10
11 use EasyInvoice\Interfaces\ClientRepositoryInterface;
12 use EasyInvoice\Repositories\ClientRepository;
13
14 /**
15 * ClientServiceProvider Class
16 *
17 * Handles registration of client-related services.
18 */
19 class ClientServiceProvider {
20 /**
21 * The repository instance
22 *
23 * @var ClientRepositoryInterface
24 */
25 protected static $repository = null;
26
27 /**
28 * Register client services
29 */
30 public function register() {
31 // Register actions and filters
32 add_action('after_setup_theme', [$this, 'registerClientRole']);
33
34 // Register client repository
35 $this->registerClientRepository();
36 }
37
38 /**
39 * Register client role if it doesn't exist
40 */
41 public function registerClientRole() {
42 $role = get_role('customer');
43
44 if (!$role) {
45 add_role('customer', __('Customer', 'easy-invoice'), [
46 'read' => true,
47 ]);
48 }
49 }
50
51 /**
52 * Register client repository
53 */
54 protected function registerClientRepository() {
55 // Create and store the repository instance
56 self::$repository = new ClientRepository();
57 }
58
59 /**
60 * Get the client repository
61 *
62 * @return ClientRepositoryInterface The client repository
63 */
64 public static function getClientRepository() {
65 // Create the repository if it doesn't exist
66 if (self::$repository === null) {
67 self::$repository = new ClientRepository();
68 }
69
70 return self::$repository;
71 }
72 }