| 1 |
<?php |
| 2 |
/** |
| 3 |
* Invoice Service Provider |
| 4 |
* |
| 5 |
* @package Easy_Invoice |
| 6 |
* @subpackage Providers |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace EasyInvoice\Providers; |
| 10 |
|
| 11 |
use EasyInvoice\Interfaces\InvoiceRepositoryInterface; |
| 12 |
use EasyInvoice\Repositories\InvoiceRepository; |
| 13 |
|
| 14 |
/** |
| 15 |
* InvoiceServiceProvider Class |
| 16 |
* |
| 17 |
* Handles the registration of invoice-related services. |
| 18 |
*/ |
| 19 |
class InvoiceServiceProvider { |
| 20 |
/** |
| 21 |
* The repository instance |
| 22 |
* |
| 23 |
* @var InvoiceRepositoryInterface |
| 24 |
*/ |
| 25 |
protected static $repository = null; |
| 26 |
|
| 27 |
/** |
| 28 |
* Register invoice services |
| 29 |
*/ |
| 30 |
public function register() { |
| 31 |
// Register service providers, load dependencies, etc. |
| 32 |
$this->registerRepositories(); |
| 33 |
$this->registerHooks(); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Register repositories |
| 38 |
*/ |
| 39 |
protected function registerRepositories() { |
| 40 |
// This method would be more useful if you're using a dependency injection container |
| 41 |
// For now, it's just a placeholder to maintain structure for future expansion |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Register hooks |
| 46 |
*/ |
| 47 |
protected function registerHooks() { |
| 48 |
// Register any WordPress hooks related to invoices |
| 49 |
// Removed duplicate textdomain loading - it's handled in the main plugin file |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Load text domain |
| 54 |
*/ |
| 55 |
public function loadTextDomain() { |
| 56 |
// Removed - textdomain is loaded in the main plugin file |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Register invoice repository |
| 61 |
*/ |
| 62 |
protected function registerInvoiceRepository() { |
| 63 |
// Create and store the repository instance |
| 64 |
self::$repository = new InvoiceRepository(); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Get the invoice repository |
| 69 |
* |
| 70 |
* @return InvoiceRepositoryInterface The invoice repository |
| 71 |
*/ |
| 72 |
public static function getInvoiceRepository() { |
| 73 |
// Create the repository if it doesn't exist |
| 74 |
if (self::$repository === null) { |
| 75 |
self::$repository = new InvoiceRepository(); |
| 76 |
} |
| 77 |
|
| 78 |
return self::$repository; |
| 79 |
} |
| 80 |
} |