Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder (or namespace) issue on subscriber #472

Closed
xDaizu opened this issue Jul 27, 2015 · 0 comments
Closed

Folder (or namespace) issue on subscriber #472

xDaizu opened this issue Jul 27, 2015 · 0 comments

Comments

@xDaizu
Copy link

xDaizu commented Jul 27, 2015

I've been banging my head to write a simple subscriber for JMS Serializer for 2 days. Finally, after trying many syntaxes unsuccessfully I found vendor/jms/serializer/src/JMS/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriber.php and just copy pasted it... and still didn't work.

My subscriber reads like this:

<?php

namespace License\StudentBundle\EventListener;

use Doctrine\ORM\PersistentCollection;
use Doctrine\Common\Persistence\Proxy;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use JMS\Serializer\EventDispatcher\PreSerializeEvent;
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;


class ProgenitorSerializationSubscriber implements EventSubscriberInterface
{
    public function onPreSerialize(PreSerializeEvent $event)
    {
        throw new \Exception("Preserializiiiiing");
    }

    public static function getSubscribedEvents()
    {
        return array(
            array('event' => 'serializer.pre_serialize', 'method' => 'onPreSerialize'),
        );
    }
}

and it doesn't work. But if I just move it to the vendor/jms/serializer/src/JMS/Serializer/EventDispatcher/Subscriber folder a rename its namespace to namespace License\StudentBundle\EventListener; it works! (or rather doesn't because it throws an exception, haha)

Anyways... WTH? What's going on (or rather isn't going on) behind the scenes? How do I make it work?

@xDaizu xDaizu closed this as completed Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant