Exercise/FOQElasticaBundle — pull request #106 by willdurand (2012-05-04 15:02:14+00:00)
Title: Made persister services public to use them

Heya,

`foq_elastica.object_persister.*.*` services are not public by default. So you can't use persister services except by injecting them at container build time. That means no way to use them in a controller for instance.

These services are useful for listeners. In Doctrine, listeners are services so it's ok, but with Propel, you don't have listeners as services. What I do is to set the `objectPersister` instance on my model object, and then hooks can use it.

For example, here is a `processForm()` method:

``` php
setObjectPersister($this->get('foq_elastica.object_persister.website.event'));

if ($form->isValid()) {
$event->save();
// ...
}
}
```

And then:

``` php
objectPersister = $objectPersister;
}

public function postSave(\PropelPDO $con = null)
{
if (null !== $this->objectPersister) {
$this->objectPersister->insertOne($this);
}
}

public function postUpdate(\PropelPDO $con = null)
{
if (null !== $this->objectPersister) {
$this->objectPersister->replaceOne($this);
}
}

public function postDelete(\PropelPDO $con = null)
{
if (null !== $this->objectPersister) {
$this->objectPersister->deleteById($this->getId());
}
}
}
```

Everything is explicit, testable, ... So far so good :)

This Pull Request just makes persisters services accessible everywhere.