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

Elastica Bundle Laravel Package

bok/elastica-bundle

View on GitHub
Deep Wiki
Context7
Pre transform event

Since FOSElasticaBundle 3.2.0, we now dispatch an event before an object is transformed into an Elastica document. It allows you to do some necessary operation before indexing.

For example, you have a backoffice which is exclusively used in a certain locale. When you save objects which have translation, you have to index objects in several indices (one per locale supported). It is necessary to reload data before transforming to document with the good locale if it is not already done.

You can even manipulate empty Elastica document created in FOS\ElasticaBundle\Transformer\ModelToElasticaAutoTransformer and fields concerned by index process.

Set up an event listener or subscriber for FOS\ElasticaBundle\Event\PreTransformEvent to be able to do some operation on your objects.


namespace AcmeBundle\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use FOS\ElasticaBundle\Event\PreTransformEvent;

class PreTransformListener implements EventSubscriberInterface
{
    private $anotherService;
    
    // ...
    
    public function doPreTransform(PreTransformEvent $event)
    {
        $this->anotherService->reloadTranslation($event->getObject());
    }
    
    public static function getSubscribedEvents()
    {
        return [
            PreTransformEvent::class => 'doPreTransform',
        ];
    }
}

Service definition (when autoconfigure is disabled):

acme.listener.custom_property:
    class: AcmeBundle\EventListener\PreTransformListener
    tags:
        - { name: kernel.event_subscriber }
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.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/opensearch-client
directorytree/opensearch-adapter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin