Doctrine tries to insert a null object Symfony 5.4 - php

when i submit my form, I have two values ​​to choose from:
WorkPlanningDay and workPlanningHour.
if workplanninghour is specified, we insert a row in the workplanninghour table and vice versa
When I submit a workPlanningHour, I want to prevent doctrine from inserting a workPlanningDay object with null data. I tried to use a $form->remove but without success.
here is my request datas :
{"statuses":[6],"work_planning":1,"work_planning_hour":{"count_jrtt":1,"end_at":"31-12","jrtt":true,"lower_hour_jrtt":35,"nbr_jrtt":24,"start_at":"01-01","upper_hour_jrtt":39},"work_planning_period":0,"working_time_aspect":{"days":["MON","TUE","WED","THU","FRI"],"time":0,"weekly_hours":35}}
here is my form with my EventListener :
class WorkingTimeParametersRESTType extends AbstractType
{
/**
* {#inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('work_planning', Field\ChoiceType::class, array(
'property_path' => 'workPlanning',
'required' => true,
'choices' => WorkingTimeParameters::getAllowedWorkPlannings(),
))
->add('work_planning_period', Field\ChoiceType::class, array(
'property_path' => 'workPlanningPeriod',
'required' => false,
'choices' => WorkingTimeParameters::getAllowedWorkPlanningPeriods(),
))
->add('working_time_aspect', WorkingTimeAspectType::class, array(
'property_path' => 'workingTimeAspect',
'required' => true,
'constraints' => array(new Valid())
))
->add('work_planning_hour', WorkPlanningHourType::class, array(
'property_path' => 'workPlanningHour',
'required' => true,
'constraints' => array(new Valid())
))
->add('work_planning_day', WorkPlanningDayType::class, array(
'property_path' => 'workPlanningDay',
'required' => true,
'constraints' => array(new Valid())
))
->add('statuses', Field\CollectionType::class, array(
'entry_type' => CategoryIntegerType::class,
'entry_options' => array(
'category_type' => Category::TYPE_STATUS,
),
'allow_add' => true,
'allow_delete' => true,
'required' => true,
'error_bubbling' => false,
))
->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'))
->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
/** #var WorkingTimeParameters $contract */
$parameters = $event->getData();
$form = $event->getForm();
// dd($form->has('work_planning_day'));
// Remove useless work planning
if ($parameters->getWorkPlanning() == Contract::WORK_PLANNING_HOUR) {
$parameters->setWorkPlanningDay(null);
$form->remove('work_planning_day');
}
else if ($parameters->getWorkPlanning() == Contract::WORK_PLANNING_DAY) {
$parameters->setWorkPlanningHour(null);
$form->remove('work_planning_hour');
}
else {
dd('rerer');
$form->remove('work_planning_day');
$form->remove('work_planning_hour');
$parameters->setWorkPlanningDay(null);
$parameters->setWorkPlanningHour(null);
$parameters->setWorkPlanningPeriod(null);
}
})
;
}
/**
* #param FormEvent $event
*/
public function onPreSetData(FormEvent $event)
{
$rttParameters = $event->getData();
$form = $event->getForm();
// The company can be set only on creation
if (!$rttParameters || !$rttParameters->getId()) {
$form->add('company', CompanyIntegerType::class, array(
'required' => true,
));
}
}
and here are the requests that doctrine is trying to launch :
INSERT INTO w2d_tm_work_planning_hour (startAt, endAt, jrtt, countJrtt, lowerHourJrtt, upperHourJrtt, nbrJrtt) VALUES ('1970-01-01 00:00:00', '1970-12-31 00:00:00', 1, 1, 35, 39, 24);
UPDATE w2d_tm_work_planning_day SET startAt = NULL, endAt = NULL, nbrDays = NULL, nbrJrtt = NULL WHERE id = 1;
how to do so that doctrine does not launch the second request with the null values ?

Symfony form type are not made to handle different entities depending on a option you selected inside.
This not how Symfony FormType are supposed to be used. This is why the data_class attribute is made for one entity.
You best option is to create two distinct FormType and submit only the one needed depending on what the user selected on frontend. (easy with a little of javascript)
The second advantage of this is you will have much more understandable and maintable code.

Related

Symfony2 collection Form uniquenes

I have a symfony2 main form, with a field what is a collection type of an other field, like a Product entity with multiple Tag, but these tag has a unique hash.
There is an eventListener attached to the main form. If I send a data to the form and I send a Tag along with this unique has, the unique constraint on the class will say, that that field has to be unique. This work good, but in this EventListener I'm search in the DB for this unique field and if it's the right one, I do an assign, I replace the post content with an entity from the DB.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('eventDate', 'datetime',array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd HH:mm',
'invalid_message' => 'Wrong datetime format. Please use like this: 2015-09-20 14:45:12',
))
->add('eventEnds', 'datetime', array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd HH:mm',
'invalid_message' => 'Wrong datetime format. Please use like this: 2015-09-20 14:45:12',
))
->add('tag','collection', array(
'type' => new TagType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
'property_path' => 'professional',
'label' => false,
'options' => array(
'professional' => true,
),
))
->addEventListener(FormEvents::SUBMIT, [$this, 'submit'])
;
}
public function preSubmit(FormEvent $event)
{
/** #var MainForm $data */
$data = $event->getData();
foreach ($data->getTags() as $tag) {
if ($tag->getId() == null && $tag->getHash()){
$tagDB = $this->entityManager
->getRepository('ApplicationBundle:Tag')
->findOneBy([
'hash' => $professional->getHash(),
]);
if ($tagDB) {
$data->removeTag($tag);
$data->addTag($tagDB);
}
}
}
$event->setData($data);
}
If I dump the $data value after the setData, I see there the entities from the DB, but I still got a Unique validation error and I check in the validator, symfony pass in the original POST content.
Why is it like that and how can I solve this problem?
Should be
->addEventListener(FormEvents::PRE_SUBMIT, [$this, 'submit'])
(PRE_SUBMIT instead of SUBMIT)
Your code should be something like:
public function preSubmit(FormEvent $event)
{
/** #var MainForm $data */
$data = $event->getData();
$num = count($data['tag']);
for ($i=0;$i<$num;$i++) {
$tag = $data['tag'][$i];
if (!isset($tag['id']) && isset($tag['hash'])){
$tagDB = $this->entityManager
->getRepository('ApplicationBundle:Tag')
->findOneBy([
'hash' => $tag['hash'],
]);
if ($tagDB) {
unset($data['tag'][$i]);
$data['tag'][$i] = array (
'id' => $tagDB->getId();
'hash' => $tagDB->getHash();
);
}
}
}
$event->setData($data);
}
Not sure the code is 100% correct as I have not been able to test it, but you get the idea.

Symfony2 form : how to populate dynamically added entity field with a query result after creation?

In a Symfony 2.7 project,
let's say we have a form composed of 2 fields 'date'(date) and 'group'(entity), both have their own EventListener attached to, for FormEvents::SUBMIT events.
After the first submit, I'd like to add a new field 'travels' to the form and populate it with the result of a query using the two previous fields as criterias.
How to prevent 'travels' entity field from fetching all 'travel' in the DB and populate it manually after the raised events ?
I certainly miss some comprehension, I'm new to Symfony.
I know I can pass data directly in 'choices' option when creating 'travels' in each event but it would make useless DB calls.
I might count the number of registered events (of interest) and create 'travels' field when last event happens but it seems kind of weird...
Is there a clean solution for this case ?
(excuse for English, not my native language)
<?php
namespace MyBundle\Form;
// use directives...
class TravelRequestsWorklistType extends AbstractType {
private $em;
private $travelRepository;
private $searchQueryBuilder;
public function __construct(EntityManager $em) {
$this->em = $em;
$this->travelRepository = $this->em->getRepository(Travel::class);
}
public function buildForm(FormBuilderInterface $builder, array $options) {
$formFactory = $builder->getFormFactory();
$builder
->add('requestedDate', 'date', array(
'widget' => 'single_text',
'input' => 'datetime',
'format' => 'dd/MM/yyyy',
'attr' => array('class' => 'date'),
'data' => null,
'mapped' => false
))
->add('selectedGroup', 'entity', array(
'class' => 'MyBundle\Entity\Group',
'placeholder' => '',
'mapped' => false,
'multiple' => false,
))
->add('search', 'submit');
$builder->get('requestedDate')->addEventListener(FormEvents::SUBMIT,
$this->onDateCriteriaEvent($formFactory));
$builder->get('selectedGroup')->addEventListener(FormEvents::SUBMIT,
$this->onGroupCriteriaEvent($formFactory));
}
private function onDateCriteriaEvent(FormFactory $ff) {
return
function(FormEvent $event) use ($ff) {
$root = $event->getForm()->getParent();
$requestedDate = $event->getData();
$qb = $this->getQueryBuilder();
$qb->andWhere('r.requestedDate = :requestedDate')
->setParameter('requestedDate', $requestedDate);
if(!$this->searchHasResult($root)) {
$this->addTravels($ff, $root);
}
};
}
private function onGroupCriteriaEvent(FormFactory $ff) {
return
function(FormEvent $event) use ($ff) {
$root = $event->getForm()->getRoot();
$selectedGroup = $event->getData();
$qb = $this->getQueryBuilder();
$qb->andWhere('r.group = :group')
->setParameter('group', $selectedGroup);
if(!$this->searchHasResult($root)) {
$this->addTravels($ff, $root);
}
};
}
private function addTravels(FormFactory $ff, Form $rootForm) {
$travels = $ff->createNamedBuilder('travels', 'entity', null,
array(
'class' => 'MyBundle\Entity\Travel',
'mapped' => false,
'multiple' => true,
'expanded' => true,
'auto_initialize' => false
));
$submitButton = $ff->createNamedBuilder('validate', 'submit');
$travels->addEventListener(FormEvents::PRE_SUBMIT, $this->onSearchResult());
$form->add($travels->getForm())->add($submitButton->getForm());
}
// The method setData() shows "This form should not contain extra fields"
private function onSearchResult() {
return
function(FormEvent $e) {
$data = $this->searchResultQueryBuilder->getQuery()->getResult();
$e->setData($data);
};
}
private function getQueryBuilder() {
if(null === $this->searchQueryBuilder) {
$this->searchResultQueryBuilder = $this->travelRepository->createQueryBuilder('r');
// add dummy where clause here in order to call "andWhere" indistinctly later
$this->searchResultQueryBuilder->where("1 = 1");
}
return $this->searchQueryBuilder;
}
private function searchHasResult(Form $form) {
return $form->has('travels');
}
}
Finally I found a piece of solution.
On $formField->addEventListener() we can set a priority order as the third argument. So I can know which event will be triggered the last.
There must be another solution (like registering all the events I want to monitor in some member array and check if they have been executed in each callback). For the moment setting hardcoded events priority without checking callbacks execution is OK (for only 2 events).
The field is populated during creation and not after but anyway, it works :).
public function buildForm(FormBuilderInterface $builder, array $options) {
$formFactory = $builder->getFormFactory();
$builder
->add('requestedDate', 'date', array(
'widget' => 'single_text',
'input' => 'datetime',
'format' => 'dd/MM/yyyy',
'attr' => array('class' => 'date'),
'data' => null,
'mapped' => false
))
->add('selectedGroup', 'entity', array(
'class' => 'MyBundle\Entity\Group',
'placeholder' => '',
'mapped' => false,
'multiple' => false,
))
->add('search', 'submit');
// Here we could use a register method which would contain listener informations
$builder->get('requestedDate')
->addEventListener(FormEvents::SUBMIT,
$this->onDateCriteriaEvent($formFactory),
0); //Will be triggered first
$builder->get('selectedGroup')
->addEventListener(FormEvents::SUBMIT,
$this->onGroupCriteriaEvent($formFactory),
1); //Will be triggered after 1st
}
private function onDateCriteriaEvent(FormFactory $ff) {
return
function(FormEvent $event) use ($ff) {
$root = $event->getForm()->getParent();
$qb = $this->getQueryBuilder();
if(null !== $event->getData()) {
$requestedDate = $event->getData();
$qb->andWhere('r.requestedDate = :requestedDate')
->setParameter('requestedDate', $requestedDate);
// Here we could check for registered events not already raised
// and do the appropriate action (if it is the last or something else...)
}
};
}
private function onGroupCriteriaEvent(FormFactory $ff) {
return
function(FormEvent $event) use ($ff) {
$qb = $this->getQueryBuilder();
$root = $event->getForm()->getRoot();
if(null !== $event->getData()) {
// Check for events not already raised....
$selectedGroup = $event->getData();
$qb->andWhere('r.group = :group')
->setParameter('group', $selectedGroup);
}
$travels = $qb->getQuery()->getResult();
if($this->searchHasResult($root) {
// We know this event is the last raised so we can add 'travels' field
$this->addTravels($ff, $root);
}
};
}
private function addTravels(FormFactory $ff, Form $rootForm) {
$travels = $ff->createNamedBuilder('travels', 'entity', null,
array(
'class' => 'MyBundle\Entity\Travel',
'mapped' => false,
'multiple' => true,
'expanded' => true,
'auto_initialize' => false
));
$submitButton = $ff->createNamedBuilder('validate', 'submit');
$travels->addEventListener(FormEvents::PRE_SUBMIT, $this->onSearchResult());
$form->add($travels->getForm())->add($submitButton->getForm());
}

Symfony2 Change checkbox values from 0/1 to 'no'/'yes'

I created a form with one checkbox.
UserSettingsType.php:
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('newsletter', 'checkbox', array(
'label' => 'Newsletter erhalten',
'attr' => array(
'class' => 'form-control',
),
'required' => false,
));
}
In the UserSettings.php Entity:
/**
* #ORM\Column(name="newsletter", type="boolean")
*/
protected $newsletter;
In the User.php:
/**
* #ORM\Column(type="integer", nullable=true)
*/
protected $user_settings_id;
/**
* #ORM\OneToOne(targetEntity="UserSettings", cascade={"persist"})
* #ORM\JoinColumn(name="user_settings_id", referencedColumnName="id")
*/
protected $settings;
In the PageController.php i handle the settings action:
public function settingsAction() {
$user = $this->getUser();
if ($user->getSettings() !== null) {
$settings = $user->getSettings();
} else {
$settings = new UserSettings($user);
}
$settings_form = $this->createForm(new UserSettingsType(), $settings);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$em = $this->getDoctrine()->getManager();
$settings_form->bind($request);
if ($settings_form->isValid()) {
$user->setSettings($settings);
$em->persist($user);
$em->flush();
}
}
return $this->render('MyCompMyAppBundle:Page:settings.html.twig', array(
'settings_form' => $settings_form->createView(),
));
}
I want to change the checkbox values from false (unchecked) / true (checked) to 'no' / 'yes' and change the definition of the newsletter field to: * #ORM\Column(name="newsletter", type="string", columnDefinition="ENUM('yes', 'no')")
It would be nice if there would be 'yes' and 'no' enum values in the database.
Please correct me if i am wrong: There is no way to change this via form element attributes, right?
I heard something about a DataTransformer:. But is there any easier way to realize this?
do you want checkbox or radio button? for checkbox in peresentation use:
$builder->add('newsletter', 'choice', array(
'label' => 'Newsletter erhalten',
'attr' => array(
'class' => 'form-control',
),
'choices' => array(array('yes' => 'yes'), array('no' => 'no')),
'expanded' => true,
'multiple' => true,
'required' => false,
));
Don't use ENUM for this!
In MySQL, use either data type BIT(1) or TINYINT(1) (=same as BOOLEAN). See here: Which MySQL data type to use for storing boolean values
In PostgreSQL, there is a true BOOLEAN type. But no ENUM. So if you're ever thinking about migrating, better get rid of ENUM ;-)

symfony2 choice form valid

I have got a simple smyfony2 form with one choices element. When I choose "kerosin" or "diesel" the form won't validate, what is correct. When I won't choose any of the three options and submit the form empty, $form->validate() will return true, but it shouldn't. Any ideas? Using the HTML5 required is not a solution for me.
This is my Form AbstractType:
public function buildForm(FormBuilderInterface $builder, array $options)
{
// Form erzeugen
$builder->add('treibstoff', 'choice', array(
'choices' => array(
'kerosin' => 'form.quiz1.kerosin',
'benzin' => 'form.quiz1.benzin',
'diesel' => 'form.quiz1.diesel',
),
'multiple' => false,
'expanded' => true,
'label' => ' '
))
->getForm();
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
// Validierung erzeugen
$collectionConstraint = new Collection(array(
'treibstoff' => array(
new Choice(array(
'choices' => array('benzin'),
'message' => 'form.quiz.falscheantwort',
'strict' => true
)
)
)
));
$resolver->setDefaults(array(
'validation_constraint' => $collectionConstraint
));
}
public function getName()
{
...
Validation works like this:
if($Request->getMethod() == "POST") {
$form->bind($Request);
if($form->isValid()) {
echo "valid";
Thanks in advance.
Edit:
I changed the setDefaultOptions like suggested and added NotBlank. That worked out for me:
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
// Validierung erzeugen
$collectionConstraint = new Collection(array(
'treibstoff' => array(
new Choice(array(
'choices' => array('benzin'),
'message' => 'form.quiz.falscheantwort',
'strict' => true,
)
),
new NotBlank()
)
));
$resolver->setDefaults(array(
'validation_constraint' => $collectionConstraint
));
}
You set only valid choice to benzin in setDefaultOptions, but you didn't specify the field as required. Note that required in form field only sets HTML5 validation on:
Also note that setting the required option to true will not result in
server-side validation to be applied. In other words, if a user
submits a blank value for the field (either with an old browser or web
service, for example), it will be accepted as a valid value unless you
use Symfony's NotBlank or NotNull validation constraint.
So, you'll have to add also NotBlank constraint to treibstoff field.

Entities passed to the choice field must be managed

I create a new object and bind it to a form. The user fills out the form and goes to a preview page. I store the user responses in the session.
The problem crops up when I try to reload the object from the session when the user goes back to edit the form. I get :
Error: the Entities passed to the choice field must be managed.
Anyone have an idea of where i might be going wrong? Heres the code for the controllers.
public function previewdealAction(Request $request){
$session = $this->getRequest()->getSession();
$coupon = $session->get('coupon');
$form = $this->createForm(new CouponType(), $coupon);
if ($request->getMethod() == 'POST') {
//bind the posted form values
$form->bindRequest($request);
//once a valid form is submitted ...
if ($form->isValid()){
//Proceed to Previewing deal
$file = $coupon->getImage();
$file->upload();
$session->set('coupon', $coupon);
$repository = $this->getDoctrine()
->getRepository('FrontendUserBundle:Coupon');
$coupons = $repository->findAll();
return $this->render('FrontendHomeBundle:Merchant:dealpreview.html.twig', array('coupon'=>$coupon, 'coupons'=>$coupons));
}
}
}
public function builddealAction(Request $request){
$em = $this->get('doctrine')->getEntityManager();
$user = $this->container->get('security.context')->getToken()->getUser();
//check for a coupon session variable
$session = $this->getRequest()->getSession();
$coupon = $session->get('coupon');
//If coupon is not set
if($coupon == NULL){
$coupon = new Coupon();
$date = new \DateTime(date("Y-m-d H:i:s"));
$coupon->setStartdate($date);
$coupon->setPosterid($user);
$session->set('coupon', $coupon);
}
$form = $this->createForm(new CouponType(), $coupon);
return $this->render('FrontendHomeBundle:Merchant:builddeal.html.twig', array(
'form' => $form->createView(),
));
}
--
namespace Frontend\HomeBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class CouponType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options) {
$builder->add('couponname', 'text');
$builder->add('description', 'textarea');
$builder->add('price', 'money', array('currency' => 'USD'));
$builder->add('originalprice', 'money', array('currency' => 'USD'));
$builder->add('maxlimit', 'integer');
$builder->add('maxper', 'integer');
$builder->add('startdate', 'date', array(
'years' => array(2011, 2012, 2013, 2014),
));
$builder->add('duration', 'choice', array(
'choices' => array(
'3' => 3,
'7' => 7,
'14' => 14,
'30' => 30,
'60' => 60,
'90' => 90,
),
'expanded' => false,
'multiple' => false,
));
$builder->add('expirationdate', 'choice', array(
'choices' => array(
'30' => 30,
'60' => 60,
'90' => 90,
'180' => 180,
),
'expanded' => false,
'multiple' => false,
));
$builder->add('tip', 'integer');
$builder->add('salestax', 'choice', array(
'choices' => array(
'included' => 'Sales tax is included and will be remitted BY YOU at the appropriate tax jurisdiction',
'exempt' => 'Sales tax is exempt according to seller\'s tax jurisdiction',
'collected' => 'Sales tax will be collected BY YOU at time of deal redemption',
),
'expanded' => true,
'multiple' => false,
));
$builder->add('signature', 'text');
$builder->add('city', 'entity', array(
'class' => 'Frontend\\UserBundle\\Entity\\Cities',
'expanded' => false,
'multiple' => false,
));
$builder->add('category', 'entity', array(
'class' => 'Frontend\\UserBundle\\Entity\\Category',
'expanded' => false,
'multiple' => false,
));
$builder->add('address', new AddressType());
$builder->add('image', new DocumentType());
$builder->add('maxper', 'choice', array(
'choices' => array(
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
'6' => 6,
'7' => 7,
'8' => 8,
'9' => 9,
'10' => 10,
),
'expanded' => false,
'multiple' => false,
));
}
public function getDefaultOptions(array $options) {
return array(
'data_class' => 'Frontend\UserBundle\Entity\Coupon',
);
}
public function getName()
{
return 'user';
}
}
heres the coupon type class
I was experiencing the same problem - I was retrieving data from a form using getData() and storing in the session. Later on, after a redirect, I was attempting to repopulate another instance of the same form using setData().
I experienced no issues with native fields. However, when my form included an entity I was receiving the same dreaded message "Entities passed to the choice field must be managed".
After some head scratching the issue revealed itself to be pretty straightforward (aren't they all?). After a redirect, the entity has become detached; the solution is simply to re-include the entity into the EntityManager using EntityManager::merge(), thus reinstating the entity as a managed object :)
// an array of form data from session
$entity = $data['my_entity'];
// merge() returns the managed entity
$entity = $this->getDoctrine()->getEntityManager()->merge($entity);
// update the form data array
$data['my_entity'] = $entity;
// Create form with form data
$form = $this->createForm(new MyFormType(), $data);
http://www.doctrine-project.org/api/orm/2.0/doctrine/orm/entitymanager.html
Hope this helps!
It's not relating to solve your specific problem but I'd like to annotate:
I've had the same problem and could solve it by removing 'by_reference' => false which was needless here and the reason for this error.
Had the same problem and used pretty much the answer Daggah supposed, but added a small loop through the array of entities, checking for objects:
if ($this->get('session')->has('filters')) {
$filters = $this->get('session')->get('filters');
foreach ($filters as $key => $filter) {
if (is_object($filter)) {
$filters[$key] = $em->merge($filter);
}
}
$filterForm = $this->createForm(new FilterType(), $filters);
}
Hope this helps someone.
I had the same problem and both answers were very helpful, but my issue involved multidimensional arrays so to keep things dynamic I used a recursive version of jahller's function.
private function manageObjects(&$data_array)
{
foreach ($data_array as $key => &$value)
if (is_object($value))
$data_array[$key] = $this->container->get('doctrine.orm.entity_manager')->merge($value);
else if (is_array($value))
$this->manageObjects($value);
}
Hope this helps someone.
More complex solution basing on prev comments.
Support ArrayCollections and DateTime objects
/**
* Merge objects
* Allow to manage object by doctrine when using stored (eg. in session data values)
* #param $data_array - list of form fields
* #return mixed
*/
public function manageObjects($data_array)
{
foreach ($data_array as $key => $value) {
// for multi choices
if ($value instanceof ArrayCollection) {
$data_array[$key] = $this->manageObjects($value);
}
//ommit dateTime object
elseif ($value instanceof \DateTime) {
}
elseif (is_object($value)) {
$data_array[$key] = $this->getService('doctrine.orm.entity_manager')->merge($value);
}
}
return $data_array;
}

Categories