public function prePersist($variety)
    {
        parent::prePersist($variety);

        if ($variety->getParent()) {
            if ($variety->getParent()->getId() == $variety->getId()) {
                $variety->setParent(null);
            }
        }

//        $config = $this->getConfigurationPool()->getContainer()->getParameter('librinfo_varieties')['variety_descriptions'];
//
//        foreach($config as $fieldset => $field){
//            $getter = 'get' . ucfirst($fieldset) . 'Descriptions';
//            $setter = 'set' . ucfirst($fieldset) . 'Descriptions';
//
//            $descs = $variety->$getter();
//
//            foreach($descs as $key =>$desc)
//                if($desc->getValue() == null || $desc->getValue() == '' || $desc->getValue() == 0)
//                    unset($descs[$key]);
//        }
    }
public function prePersist($variety)
    {
        parent::prePersist($variety);

        if ($variety->getParent()) {
            if ($variety->getParent()->getId() == $variety->getId()) {
                $variety->setParent(null);
            }
        }

//        $config = $this->getConfigurationPool()->getContainer()->getParameter('librinfo_varieties')['variety_descriptions'];
//
//        foreach($config as $fieldset => $field){
//            $getter = 'get' . ucfirst($fieldset) . 'Descriptions';
//            $setter = 'set' . ucfirst($fieldset) . 'Descriptions';
//
//            $descs = $variety->$getter();
//
//            foreach($descs as $key =>$desc)
//                if($desc->getValue() == null || $desc->getValue() == '' || $desc->getValue() == 0)
//                    unset($descs[$key]);
//        }
    }
public function prePersist ( $ variety ) { parent :: prePersist ( $ variety ) ; if ( $ variety -> getParent ( ) ) { if ( $ variety -> getParent ( ) -> getId ( ) == $ variety -> getId ( ) ) { $ variety -> setParent ( null ) ; } } //        $config = $this->getConfigurationPool()->getContainer()->getParameter('librinfo_varieties')['variety_descriptions']; // //        foreach($config as $fieldset => $field){ //            $getter = 'get' . ucfirst($fieldset) . 'Descriptions'; //            $setter = 'set' . ucfirst($fieldset) . 'Descriptions'; // //            $descs = $variety->$getter(); // //            foreach($descs as $key =>$desc) //                if($desc->getValue() == null || $desc->getValue() == '' || $desc->getValue() == 0) //                    unset($descs[$key]); //        } }
prevent primary key loop
prevent primary key loop