Installation Add the bundle to your Laravel/OroCommerce project via Composer:
composer require dylvn/core-bundle
Register the bundle in config/bundles.php:
return [
// ...
Dylvn\CoreBundle\DylvnCoreBundle::class => ['all' => true],
];
First Use Case The bundle provides foundational utilities for OroCommerce integrations. Start by leveraging its event system or service container extensions:
use Dylvn\CoreBundle\Event\DylvnEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
// Dispatch a custom event
$dispatcher->dispatch(new DylvnEvent('custom.event.name'));
Key Entry Points
config/packages/dylvn_core.yaml for default settings.src/DependencyInjection/DylvnCoreExtension.php for available services.src/Event/ for extensible event classes.Event-Driven Extensions Extend OroCommerce workflows by subscribing to Dylvn events:
// In a service or controller
$dispatcher->addListener(DylvnEvent::PRE_PROCESS, function (DylvnEvent $event) {
if ($event->getName() === 'order.pre_save') {
$event->setData(['custom_field' => 'value']);
}
});
Service Integration
Use the bundle’s services (e.g., dylvn.core.logger) for cross-cutting concerns:
$logger = $container->get('dylvn.core.logger');
$logger->info('Custom OroCommerce integration', ['context' => 'order']);
Configuration Overrides
Override default settings in config/packages/dylvn_core.yaml:
dylvn_core:
api:
enabled: true
timeout: 30
OroCommerce Dependency
oro/platform).composer.json for Oro version constraints.Event Naming Collisions
dylvn.order.pre_save).Service Container Conflicts
replace tags in services.yaml sparingly; prefer composition.$dispatcher->addListener(DylvnEvent::class, function ($event) {
if (app()->environment('dev')) {
error_log('Event: ' . get_class($event));
}
});
php bin/console debug:config dylvn_core to inspect loaded settings.Custom Events
Extend DylvnEvent to create domain-specific events:
class CustomOrderEvent extends DylvnEvent {
public function __construct(string $orderId, array $metadata) {
parent::__construct('custom.order.event');
$this->orderId = $orderId;
$this->metadata = $metadata;
}
}
Service Decorators Decorate bundle services to modify behavior:
# config/services.yaml
services:
dylvn.core.logger:
decorates: dylvn.core.logger
arguments: ['@dylvn.core.logger.inner']
Twig Extensions Add Dylvn-specific Twig filters/functions:
// src/Twig/DylvnExtension.php
class DylvnExtension extends \Twig\Extension\AbstractExtension {
public function getFilters() {
return [
new \Twig\TwigFilter('dylvn_format_currency', [$this, 'formatCurrency']),
];
}
}
How can I help you explore Laravel packages today?