Skip to content

fos_elastica.post_transform not working with serializer #1142

@eloirobe

Description

@eloirobe

Hello

I Have an issue when I use the serializer option. When the serializer is disabled the fos_elastica.post_transform event is called but when I enable the serializer option, the post_transform is not called.

These are my files:

fos_elastica:
    clients:
        default: { host: %elastic_host%, port: %elastic_port% }
->  serializer:
->    callback_class: FOS\ElasticaBundle\Serializer\Callback
->    serializer: jms_serializer

    indexes:
        lyra:
            use_alias: true
            settings:
                index:
                    analysis:
                        analyzer:
                            my_analyzer:
                                type: custom
                                tokenizer: keyword
                                filter: [lowercase, asciifolding]
            types:
                expediente:
                    indexable_callback: 'isEnabled'
                    mappings:
                        id: ~
                        barcode: ~
                    persistence:
                        driver: orm
                        model: Domain\Entity
                        provider: ~
                        listener: ~
                        finder: ~
                    serializer:
                        groups: ['elastica']
class CustomPropertyListener implements EventSubscriberInterface
{

    public function addCustomProperty(TransformEvent $event)
    {
            $document = $event->getDocument();
            $document->set('newkey', 'value');
    }

    public static function getSubscribedEvents()
    {
        return array(
            TransformEvent::POST_TRANSFORM => 'addCustomProperty',
        );
    }
}

[vagrant@dev]$ composer -i show | grep -e "elastic\|serializer\|symfony"
You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.
behat/symfony2-extension                2.1.1              Symfony2 framework extension for Behat
friendsofsymfony/elastica-bundle        3.2.0              Elasticsearch PHP integration for your Symfony2 project using Elastica
friendsofsymfony/rest-bundle            1.7.7              This Bundle provides various tools to rapidly develop RESTful API's with Symfony
friendsofsymfony/user-bundle            dev-master 4cb7a29 Symfony FOSUserBundle
jms/serializer                          1.3.1              Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle                   1.1.0              Allows you to easily serialize, and deserialize data of any complexity
ruflin/elastica                         2.3.1              Elasticsearch Client
symfony/assetic-bundle                  v2.8.0             Integrates Assetic into Symfony2
symfony/monolog-bundle                  2.11.1             Symfony MonologBundle
symfony/polyfill-apcu                   v1.2.0             Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu               v1.2.0             Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring               v1.2.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php54                  v1.2.0             Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55                  v1.2.0             Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56                  v1.2.0             Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                  v1.2.0             Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                   v1.2.0             Symfony utilities for portability of PHP codes
symfony/security-acl                    v3.0.0             Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle              v2.3.11            Symfony SwiftmailerBundle
symfony/symfony                         v2.8.11            The Symfony PHP framework

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions