PHP code example of as-cornell / as_webhook_entities

1. Go to this page and download the library: Download as-cornell/as_webhook_entities library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

as-cornell / as_webhook_entities example snippets


   'my_type' => new MyTypeWebhookHandler($entity_type_manager),
   

as_webhook_entities/
├── src/
│   ├── WebhookCrudManager.php              - Thin dispatcher, shared CRUD logic
│   ├── WebhookUuidLookup.php               - Looks up existing entities by UUID
│   ├── WebhookHandler/
│   │   ├── WebhookHandlerInterface.php     - applyCreateFields / applyUpdateFields
│   │   ├── WebhookHandlerBase.php          - Shared lookup helpers
│   │   ├── PersonWebhookHandler.php
│   │   ├── ArticleWebhookHandler.php
│   │   ├── MediaReportEntryWebhookHandler.php
│   │   ├── MediaReportPersonWebhookHandler.php
│   │   └── TermWebhookHandler.php
│   └── Plugin/QueueWorker/
│       └── WebhookEntitiesQueue.php        - Queue processor, event dispatcher
bash
   lando drush php-eval "
   \$lookup = \Drupal::service('as_webhook_entities.uuid_lookup');
   \$entity = \$lookup->findEntity('YOUR-UUID-HERE', 'person');
   echo \$entity ? 'Found: ' . \$entity->id() : 'Not found';
   "
   
bash
   lando drush php-eval "
   \$payload = json_encode([
     'event' => 'create',
     'type' => 'person',
     'uuid' => 'test-uuid-001',
     'status' => '1',
     'uid' => '1',
     'title' => 'Test Person',
     'field_departments_programs' => [],
     'field_overview_research' => [],
     'field_links' => [],
   ]);
   \Drupal::queue('webhook_entities_processor')->createItem(\$payload);
   echo 'Queued.' . PHP_EOL;
   "
   lando drush queue:run webhook_entities_processor
   
bash
   lando drush php-eval "
   \$fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'article');
   echo implode(', ', array_keys(\$fields));
   "