Installation
composer require certunlp/ngen-bundle
Add the bundle to config/bundles.php:
return [
// ...
Certunlp\NgenBundle\CertunlpNgenBundle::class => ['all' => true],
];
Database Migration Run the bundle’s migrations:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
Check vendor/certunlp/ngen-bundle/migrations/ for schema details.
First Use Case: Create an Incident Use the provided CRUD controller or create a custom one:
use Certunlp\NgenBundle\Entity\Incident;
use Certunlp\NgenBundle\Repository\IncidentRepository;
$incident = new Incident();
$incident->setTitle('Test Incident')
->setDescription('Debugging issue')
->setStatus('open');
$entityManager->persist($incident);
$entityManager->flush();
Access the Admin Interface
Navigate to /admin/incidents (default route) to manage incidents via the bundle’s built-in admin panel.
Incident Lifecycle Management
Incident entity methods (setStatus(), setPriority()) to model workflows (e.g., open → in_progress → resolved).$incident->setStatus('resolved')
->setResolutionNotes('Fixed in v1.2.0')
->setResolvedAt(new \DateTime());
Custom Fields via Extensions
Extend the Incident entity to add domain-specific fields:
namespace App\Entity;
use Certunlp\NgenBundle\Entity\Incident as BaseIncident;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Incident extends BaseIncident
{
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $customField;
// Getters/setters...
}
Event Listeners for Automation
Subscribe to bundle events (e.g., incident.status_changed) to trigger actions:
namespace App\EventListener;
use Certunlp\NgenBundle\Event\IncidentStatusChangedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class IncidentStatusListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
IncidentStatusChangedEvent::class => 'onStatusChanged',
];
}
public function onStatusChanged(IncidentStatusChangedEvent $event)
{
if ($event->getNewStatus() === 'resolved') {
// Send Slack notification, etc.
}
}
}
API Integration Use Symfony’s Serializer to expose incidents via API:
# config/packages/api_platform.yaml
api_platform:
formats:
jsonld: ['application/ld+json']
resources:
- Certunlp\NgenBundle\Entity\Incident
Bulk Actions
Leverage the IncidentRepository for batch operations:
$repository->updateStatus(['open'], 'in_progress');
IncidentType for pre-configured form fields:
use Certunlp\NgenBundle\Form\Type\IncidentType;
$form = $this->createForm(IncidentType::class, $incident);
active_incidents):
$repository->createQueryBuilder('i')
->andWhere('i.status = :status')
->setParameter('status', 'open');
translations/messages.en.yaml:
certunlp_ngen:
incident:
status:
open: "Pending Review"
Migration Conflicts
Incident entity, run migrations after schema changes:
php bin/console doctrine:schema:update --force
Admin Panel Overrides
templates/bundles/certunlpngen/.vendor/certunlp/ngen-bundle/Resources/views/admin/incident/index.html.twig to your project.Event Dispatching
services.yaml:
services:
App\EventListener\IncidentStatusListener:
tags:
- { name: kernel.event_subscriber }
Performance with Large Datasets
DISTINCT in queries to avoid N+1 issues:
$repository->createQueryBuilder('i')
->select('DISTINCT i.id')
->addSelect('u'); // Join with User entity
$entityManager->flush(); // Critical after persist()!
php bin/console cache:clear
Check var/log/dev.log for Twig/Doctrine errors.Custom Incident Types
Implement Certunlp\NgenBundle\Service\IncidentTypeInterface for domain-specific logic:
namespace App\Service;
use Certunlp\NgenBundle\Service\IncidentTypeInterface;
class SecurityIncidentType implements IncidentTypeInterface
{
public function getType(): string
{
return 'security';
}
public function validate(Incident $incident): bool
{
return $incident->getDescription()->contains('vulnerability');
}
}
Register in services.yaml:
services:
App\Service\SecurityIncidentType:
tags:
- { name: certunlp_ngen.incident_type }
Hooks for Pre/Post Actions
Use the bundle’s IncidentLifecycleEvents to intercept actions:
$dispatcher->dispatch(new IncidentPreCreateEvent($incident));
Custom Validation Add constraints to extended entities:
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity]
class Incident extends BaseIncident
{
#[Assert\Length(min: 10)]
private $description;
}
config/packages/certunlp_ngen.yaml:
certunlp_ngen:
default_status: 'pending' # Overrides 'open'
config/packages/certunlp_ngen.yaml:
certunlp_ngen:
attachments:
upload_dir: '%kernel.project_dir%/var/incident_attachments'
How can I help you explore Laravel packages today?