Weave 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.
thomas-0816/doctrine-dbal-duckdb
moyisoft/laravel-admin
oxygen/mod-pages
oxygen/mod-import-export
oxygen/mod-media
ksoft/laravel-contentbuilderjs
ourgoldpackages/exchange
mikkimike/laravel-exchange1c
wandesnet/mercadopago-laravel
tsfcorp/email
larafony/core
laravel-enso/currencies
tartan/laravel-online-payment
gam/laravel-sat-catalogs
cloudcreativity/laravel-stripe
abdulelahragih/querybuilder
wedevbr/celcoin-laravel
surazdott/nepali-date
devsquad-cockpit/laravel
coding-socks/laravel-upload-handler