Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Domainator9K Apptype Drupalseven Bundle Laravel Package

digipolisgent/domainator9k-apptype-drupalseven-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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],
    ];
    
  2. 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.

  3. 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'));
    }
    

Implementation Patterns

Common Workflows

  1. 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);
    
  2. Field Handling Access fields via dot notation:

    $title = $node['field_title'][0]['value'];
    $image = $node['field_image'][0]['uri'];
    
  3. Taxonomy Integration Fetch terms or attach them to nodes:

    $terms = $this->drupal7Service->getTerms(['vocabulary' => 'tags']);
    $this->drupal7Service->attachTermsToNode(123, [1, 2, 3]);
    
  4. 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)
        }
    });
    

Integration Tips

  • Laravel Cache: Cache frequent Drupal 7 API calls:
    $nodes = Cache::remember("drupal_nodes_{$type}", now()->addHours(1), function () use ($type) {
        return $this->drupal7Service->getNodes(['type' => $type]);
    });
    
  • Queue Jobs: Offload heavy syncs to queues:
    SyncDrupalNodesJob::dispatch($drupal7Service, ['type' => 'article']);
    
  • API Rate Limiting: Respect Drupal 7’s services.yml limits (e.g., max_cache_time).

Gotchas and Tips

Pitfalls

  1. Deprecated Drupal 7 APIs

    • The bundle may rely on Drupal 7’s older APIs (e.g., node_load()). If the target Drupal site uses custom modules, test thoroughly for compatibility.
    • Fix: Override service definitions in config/services.yaml to mock deprecated calls.
  2. Serialization Issues

    • Complex Drupal 7 data (e.g., field_collection_item) may not serialize/deserialize cleanly in Laravel.
    • Fix: Use json_encode()/json_decode() with JSON_PRESERVE_ZERO_FRACTION for floats.
  3. Time Zone Mismatches

    • Drupal 7 and Laravel may use different time zones, causing date inconsistencies.
    • Fix: Normalize timestamps:
      $created = Carbon::parse($node['created'])->setTimezone('UTC');
      
  4. CSRF Token Expiry

    • Drupal 7’s drupal_post_form() may fail if the CSRF token expires during batch operations.
    • Fix: Implement token refresh logic or use drupal_http_request() for critical operations.

Debugging

  • 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);
    

Extension Points

  1. 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')
        );
    });
    
  2. Event Listeners Subscribe to bundle events (e.g., Drupal7SyncEvent) in EventSubscriber:

    public static function getSubscribedEvents()
    {
        return [
            Drupal7SyncEvent::class => 'onSync',
        ];
    }
    
  3. Override Templates Publish and modify the bundle’s Twig templates (if used) via:

    php artisan vendor:publish --tag=domainator9k-apptype-drupal7-views
    

Configuration Quirks

  • 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);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle