PHP code example of openeuropa / oe_search

1. Go to this page and download the library: Download openeuropa/oe_search 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/ */

    

openeuropa / oe_search example snippets




namespace Drupal\mymodule\EventSubscriber;

use Drupal\oe_search\Event\DocumentCreationEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class AlterIndexedDocSubscriber implements EventSubscriberInterface {

  public static function getSubscribedEvents(): array {
    return [DocumentCreationEvent::class => 'setReleased'];
  }

  public function setReleased(DocumentCreationEvent $event): void {
    $entity = $event->getEntity();
    if ($entity->getEntityTypeId() === 'foo') {
      $event->getDocument()->setUrl("http://example.com/{$entity->uuid()}");
    }
  }

}