src/Command/CustomFieldUpdateCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine.orm.entity_manager');

        // disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops)
        $listenerInst = null;
        foreach ($em->getEventManager()->getListeners() as $event => $listeners) {
            foreach ($listeners as $hash => $listener) {
                if ($listener instanceof \CubeTools\CubeCustomFieldsBundle\EventListener\CustomFieldLinkedEntityListener) {
                    $listenerInst = $listener;
                    break 2;
                }
            }
        }
        $evm = $em->getEventManager();
        $evm->removeEventListener(array('onFlush'), $listenerInst);

        // datetime custom fields
        $datetimeCf = $em->getRepository('CubeCustomFieldsBundle:DatetimeCustomField')->findAll();
        $this->updateCfEntities($datetimeCf);
        $em->flush();

        // text custom fields
        $textCf = $em->getRepository('CubeCustomFieldsBundle:TextCustomField')->findAll();
        $this->updateCfEntities($textCf);
        $em->flush();

        // textarea custom fields
        $textareaCf = $em->getRepository('CubeCustomFieldsBundle:TextareaCustomField')->findAll();
        $this->updateCfEntities($textareaCf);
        $em->flush();

        // entity custom fields
        $entityCf = $em->getRepository('CubeCustomFieldsBundle:EntityCustomField')->findAll();
        $this->updateCfEntities($entityCf);
        $em->flush();
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine.orm.entity_manager');

        // disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops)
        $listenerInst = null;
        foreach ($em->getEventManager()->getListeners() as $event => $listeners) {
            foreach ($listeners as $hash => $listener) {
                if ($listener instanceof \CubeTools\CubeCustomFieldsBundle\EventListener\CustomFieldLinkedEntityListener) {
                    $listenerInst = $listener;
                    break 2;
                }
            }
        }
        $evm = $em->getEventManager();
        $evm->removeEventListener(array('onFlush'), $listenerInst);

        // datetime custom fields
        $datetimeCf = $em->getRepository('CubeCustomFieldsBundle:DatetimeCustomField')->findAll();
        $this->updateCfEntities($datetimeCf);
        $em->flush();

        // text custom fields
        $textCf = $em->getRepository('CubeCustomFieldsBundle:TextCustomField')->findAll();
        $this->updateCfEntities($textCf);
        $em->flush();

        // textarea custom fields
        $textareaCf = $em->getRepository('CubeCustomFieldsBundle:TextareaCustomField')->findAll();
        $this->updateCfEntities($textareaCf);
        $em->flush();

        // entity custom fields
        $entityCf = $em->getRepository('CubeCustomFieldsBundle:EntityCustomField')->findAll();
        $this->updateCfEntities($entityCf);
        $em->flush();
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ em = $ this -> getContainer ( ) -> get ( 'doctrine.orm.entity_manager' ) ; // disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops) $ listenerInst = null ; foreach ( $ em -> getEventManager ( ) -> getListeners ( ) as $ event => $ listeners ) { foreach ( $ listeners as $ hash => $ listener ) { if ( $ listener instanceof \ CubeTools \ CubeCustomFieldsBundle \ EventListener \ CustomFieldLinkedEntityListener ) { $ listenerInst = $ listener ; break 2 ; } } } $ evm = $ em -> getEventManager ( ) ; $ evm -> removeEventListener ( array ( 'onFlush' ) , $ listenerInst ) ; // datetime custom fields $ datetimeCf = $ em -> getRepository ( 'CubeCustomFieldsBundle:DatetimeCustomField' ) -> findAll ( ) ; $ this -> updateCfEntities ( $ datetimeCf ) ; $ em -> flush ( ) ; // text custom fields $ textCf = $ em -> getRepository ( 'CubeCustomFieldsBundle:TextCustomField' ) -> findAll ( ) ; $ this -> updateCfEntities ( $ textCf ) ; $ em -> flush ( ) ; // textarea custom fields $ textareaCf = $ em -> getRepository ( 'CubeCustomFieldsBundle:TextareaCustomField' ) -> findAll ( ) ; $ this -> updateCfEntities ( $ textareaCf ) ; $ em -> flush ( ) ; // entity custom fields $ entityCf = $ em -> getRepository ( 'CubeCustomFieldsBundle:EntityCustomField' ) -> findAll ( ) ; $ this -> updateCfEntities ( $ entityCf ) ; $ em -> flush ( ) ; }
Cleans up access rights

@param InputInterface $input
@param OutputInterface $output
@return boolean
Cleans up access rights