Create custom processor as described in documentation:
A alice processor can be used to manipulate a object before and after persisting. To register a own processor, create a service and tag it.
Create processor whenever you want (for ex. AppBundle\DataFixtures\MyProcessor
:
<?php
namespace AppBundle\DataFixtures;
use Nelmio\Alice\ProcessorInterface;
class MyProcessor implements ProcessorInterface
{
/**
* @param object $object instance to process
*/
public function preProcess($object)
{
if (!$object instanceof AppBundle\Entity\UserAccount) {
return;
}
$object->setEnabled($object->getConfirmed());
}
/**
* @param object $object instance to process
*/
public function postProcess($object)
{
}
}
Add service:
services:
my.alice.processor:
class: AppBundle\DataFixtures\MyProcessor
tags:
- { name: h4cc_alice_fixtures.processor }