- Hinzufügen der DependencyInjection-Konfiguration für das Billing-Modul. - Erstellen der Invoice-Entity mit API-Ressourcen und Berechtigungen. - Konfigurieren der Services in services.yaml für das Billing-Modul. - Implementieren von CLI-Commands zur Verwaltung von Modul-Lizenzen und zur Auflistung installierter Module. - Erstellen eines API-Controllers zur Verwaltung von Modulen und Lizenzen. - Hinzufügen eines EventListeners für das Booten von Modulen. - Definieren von Interfaces für Lizenzvalidierung und Modul-Plugins. - Implementieren der ModuleRegistry zur Verwaltung und Booten von Modulen. - Erstellen eines LicenseValidator-Services zur Validierung und Registrierung von Lizenzen.
69 lines
2.3 KiB
PHP
69 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace MyCRM\BillingModule\DependencyInjection;
|
|
|
|
use Symfony\Component\Config\FileLocator;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
|
|
|
/**
|
|
* Container-Extension für das Billing-Bundle
|
|
*
|
|
* Lädt Services, Konfiguration und registriert das Plugin
|
|
*/
|
|
class BillingExtension extends Extension
|
|
{
|
|
public function load(array $configs, ContainerBuilder $container): void
|
|
{
|
|
// Bundle-Konfiguration verarbeiten
|
|
$configuration = new Configuration();
|
|
$config = $this->processConfiguration($configuration, $configs);
|
|
|
|
// Services laden
|
|
$loader = new YamlFileLoader(
|
|
$container,
|
|
new FileLocator(__DIR__ . '/../../config')
|
|
);
|
|
$loader->load('services.yaml');
|
|
|
|
// Konfigurationswerte als Parameter setzen
|
|
$container->setParameter('billing.pdf_template', $config['pdf_template']);
|
|
$container->setParameter('billing.invoice_prefix', $config['invoice_prefix']);
|
|
$container->setParameter('billing.payment_gateway', $config['payment_gateway']);
|
|
|
|
// Doctrine-Mappings registrieren
|
|
$this->registerDoctrineMapping($container);
|
|
}
|
|
|
|
/**
|
|
* Registriert Doctrine-Entity-Mappings für das Modul
|
|
*/
|
|
private function registerDoctrineMapping(ContainerBuilder $container): void
|
|
{
|
|
$bundles = $container->getParameter('kernel.bundles');
|
|
|
|
if (isset($bundles['DoctrineBundle'])) {
|
|
// Doctrine-Mapping für Entities registrieren
|
|
$container->prependExtensionConfig('doctrine', [
|
|
'orm' => [
|
|
'mappings' => [
|
|
'BillingModule' => [
|
|
'is_bundle' => false,
|
|
'type' => 'attribute',
|
|
'dir' => '%kernel.project_dir%/vendor/mycrm/billing-module/src/Entity',
|
|
'prefix' => 'MyCRM\BillingModule\Entity',
|
|
'alias' => 'BillingModule',
|
|
],
|
|
],
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function getAlias(): string
|
|
{
|
|
return 'billing';
|
|
}
|
|
}
|