digipolisgent/domainator9k-apptype-drupalseven-bundle
Installation Add the bundle via Composer:
composer require digipolisgent/domainator9k-apptype-drupalseven-bundle
Register the bundle in config/bundles.php:
return [
// ...
DigipolisGent\Domainator9kApptypeDrupalSevenBundle\Domainator9kApptypeDrupalSevenBundle::class => ['all' => true],
];
Configuration Publish the default config (if needed):
php artisan vendor:publish --tag=domainator9k-apptype-drupal7-config
Edit config/domainator9k_apptype_drupal7.php to define Drupal 7 app connections.
First Use Case: Fetching Drupal 7 Data Inject the service in a controller or command:
use DigipolisGent\Domainator9kApptypeDrupalSevenBundle\Service\Drupal7Service;
public function __construct(private Drupal7Service $drupal7Service) {}
public function fetchContent()
{
$nodes = $this->drupal7Service->getNodes(['type' => 'article']);
return view('drupal_content', compact('nodes'));
}
CRUD Operations Use the service methods for common Drupal 7 interactions:
// Create
$node = $this->drupal7Service->createNode(['title' => 'Test', 'type' => 'page']);
// Read
$node = $this->drupal7Service->getNode(123);
// Update
$this->drupal7Service->updateNode(123, ['title' => 'Updated']);
// Delete
$this->drupal7Service->deleteNode(123);
Field Handling Access fields via dot notation:
$title = $node['field_title'][0]['value'];
$image = $node['field_image'][0]['uri'];
Taxonomy Integration Fetch terms or attach them to nodes:
$terms = $this->drupal7Service->getTerms(['vocabulary' => 'tags']);
$this->drupal7Service->attachTermsToNode(123, [1, 2, 3]);
Event-Driven Sync
Use the Drupal7SyncEvent to trigger actions post-sync:
$this->drupal7Service->syncNodes(function ($nodes) {
foreach ($nodes as $node) {
// Process nodes (e.g., cache, transform)
}
});
$nodes = Cache::remember("drupal_nodes_{$type}", now()->addHours(1), function () use ($type) {
return $this->drupal7Service->getNodes(['type' => $type]);
});
SyncDrupalNodesJob::dispatch($drupal7Service, ['type' => 'article']);
services.yml limits (e.g., max_cache_time).Deprecated Drupal 7 APIs
node_load()). If the target Drupal site uses custom modules, test thoroughly for compatibility.config/services.yaml to mock deprecated calls.Serialization Issues
field_collection_item) may not serialize/deserialize cleanly in Laravel.json_encode()/json_decode() with JSON_PRESERVE_ZERO_FRACTION for floats.Time Zone Mismatches
$created = Carbon::parse($node['created'])->setTimezone('UTC');
CSRF Token Expiry
drupal_post_form() may fail if the CSRF token expires during batch operations.drupal_http_request() for critical operations.Enable Verbose Logging
Add to config/domainator9k_apptype_drupal7.php:
'debug' => env('APP_DEBUG', false),
Logs will appear in storage/logs/laravel.log.
Drupal 7 Debug Module
Enable Drupal 7’s devel module to inspect raw API responses:
$this->drupal7Service->setDebug(true);
Custom Services Extend the base service by binding your class:
$this->app->bind(Drupal7Service::class, function ($app) {
return new CustomDrupal7Service(
$app->make('domainator9k_apptype_drupal7.client'),
$app->make('cache')
);
});
Event Listeners
Subscribe to bundle events (e.g., Drupal7SyncEvent) in EventSubscriber:
public static function getSubscribedEvents()
{
return [
Drupal7SyncEvent::class => 'onSync',
];
}
Override Templates Publish and modify the bundle’s Twig templates (if used) via:
php artisan vendor:publish --tag=domainator9k-apptype-drupal7-views
Multi-Environment Connections
Define separate connections in config/domainator9k_apptype_drupal7.php:
'connections' => [
'local' => [
'base_url' => 'http://drupal.local',
'username' => env('DRUPAL_USERNAME'),
],
'production' => [
'base_url' => env('DRUPAL_PROD_URL'),
'username' => env('DRUPAL_PROD_USERNAME'),
],
],
Switch via:
$this->drupal7Service->setConnection('production');
Caching Strategies Disable caching for development:
$this->drupal7Service->setCacheEnabled(false);
How can I help you explore Laravel packages today?