Installation:
composer require 20steps/drupal-bundle
Ensure Drupal 7 is installed in web/ (default) or configure ekino_drupal.root in config/packages/ekino_drupal.yaml.
Basic Configuration:
Update config/packages/ekino_drupal.yaml with:
ekino_drupal:
root: "%kernel.project_dir%/web"
strategy_id: ekino.drupal.delivery_strategy.symfony
First Use Case:
Use Drupal’s DrupalFlashBag in a Symfony controller to leverage Drupal’s messaging system:
use Ekino\Bundle\DrupalBundle\Port\DrupalFlashBag;
public function index(DrupalFlashBag $flashBag) {
$flashBag->add('status', 'Hello from Symfony!');
// Render Drupal's message queue via Symfony's templating.
}
Drupal Entity Access: Fetch Drupal entities (e.g., nodes) via configured repositories:
$repository = $this->get('ekino_drupal.entity_repository.page');
$node = $repository->find(1);
Symfony-Drupal Session Sync:
Use DrupalAttributeBag to store Symfony session data in Drupal’s session table:
$session->getBag('ekino_drupal')->set('user_pref', 'dark_mode');
Command-Line Drupal Integration: Access Drupal’s database or services in Symfony commands:
use Drupal\Core\Database\Database;
public function handle() {
$db = Database::getConnection();
$result = $db->query("SELECT * FROM node")->fetchAll();
}
/node/1).provider_keys to attach Symfony’s security token to Drupal’s authenticated requests.Drupal 7 Dependency:
drupal/core-recommended to 7.x in composer.json if auto-updating.Session Conflicts:
session.storage_id without configuring DrupalSessionStorage will cause RuntimeException.ekino.drupal.session.storage is registered in services.Entity Repository Caching:
ekino_drupal.entity_repository.unknown) throws InvalidArgumentException.ekino_drupal.entity_repositories.ekino.drupal.logger.watchdog to debug Drupal-Symfony interactions. Logs appear in Drupal’s watchdog table.doctrine or raw PDO.Custom Delivery Strategies:
Extend ekino.drupal.delivery_strategy.symfony to modify how Symfony routes to Drupal or vice versa.
services:
app.drupal_strategy:
class: App\Strategy\CustomDrupalStrategy
tags: ['ekino_drupal.delivery_strategy']
Flash Message Handlers:
Override DrupalFlashBag to customize message types or storage:
class CustomFlashBag extends DrupalFlashBag {
public function add($type, $message) {
// Custom logic (e.g., log to Symfony's monolog).
parent::add($type, $message);
}
}
Entity Repository Extensions:
Subclass Ekino\Bundle\DrupalBundle\Entity\EntityRepository to add custom methods:
class CustomNodeRepository extends EntityRepository {
public function findByTitle($title) { ... }
}
Register it in entity_repositories config.
How can I help you explore Laravel packages today?