Bundle/CoreBundle/EventSubscriber/WidgetSubscriber.php
public function onFlush(OnFlushEventArgs $args)
    {
        $this->em = $args->getEntityManager();
        $this->uow = $this->em->getUnitOfWork();
        $this->widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
        $this->viewRepo = $this->em->getRepository('Victoire\Bundle\CoreBundle\Entity\View');

        $updatedEntities = $this->uow->getScheduledEntityUpdates();
        $deletedEntities = $this->uow->getScheduledEntityDeletions();

        //Update View's CSS and inheritors of updated and deleted widgets
        foreach (array_merge($updatedEntities, $deletedEntities) as $entity) {
            if (!($entity instanceof Widget)) {
                continue;
            }

            /* @var Widget $entity */
            $widgetMap = $entity->getWidgetMap();
            if ($widgetMap->getAction() !== WidgetMap::ACTION_DELETE) {
                $view = $widgetMap->getView();
                if ($this->em->contains($view)) {
                    $this->updateViewCss($view);
                    $this->setTemplateInheritorsCssToUpdate($view);
                }
            }
        }

        //Remove CSS of deleted View and update its inheritors
        foreach ($deletedEntities as $entity) {
            if (!($entity instanceof View)) {
                continue;
            }

            $this->viewCssBuilder->removeCssFile($entity->getCssHash());
            $this->setTemplateInheritorsCssToUpdate($entity);
        }

        //Update CSS of updated View and its inheritors
        foreach ($updatedEntities as $entity) {
            if (!($entity instanceof View)) {
                continue;
            }

            $this->updateViewCss($entity);
            $this->setTemplateInheritorsCssToUpdate($entity);
        }

        $this->uow->computeChangeSets();
    }
public function onFlush(OnFlushEventArgs $args)
    {
        $this->em = $args->getEntityManager();
        $this->uow = $this->em->getUnitOfWork();
        $this->widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
        $this->viewRepo = $this->em->getRepository('Victoire\Bundle\CoreBundle\Entity\View');

        $updatedEntities = $this->uow->getScheduledEntityUpdates();
        $deletedEntities = $this->uow->getScheduledEntityDeletions();

        //Update View's CSS and inheritors of updated and deleted widgets
        foreach (array_merge($updatedEntities, $deletedEntities) as $entity) {
            if (!($entity instanceof Widget)) {
                continue;
            }

            /* @var Widget $entity */
            $widgetMap = $entity->getWidgetMap();
            if ($widgetMap->getAction() !== WidgetMap::ACTION_DELETE) {
                $view = $widgetMap->getView();
                if ($this->em->contains($view)) {
                    $this->updateViewCss($view);
                    $this->setTemplateInheritorsCssToUpdate($view);
                }
            }
        }

        //Remove CSS of deleted View and update its inheritors
        foreach ($deletedEntities as $entity) {
            if (!($entity instanceof View)) {
                continue;
            }

            $this->viewCssBuilder->removeCssFile($entity->getCssHash());
            $this->setTemplateInheritorsCssToUpdate($entity);
        }

        //Update CSS of updated View and its inheritors
        foreach ($updatedEntities as $entity) {
            if (!($entity instanceof View)) {
                continue;
            }

            $this->updateViewCss($entity);
            $this->setTemplateInheritorsCssToUpdate($entity);
        }

        $this->uow->computeChangeSets();
    }
public function onFlush ( OnFlushEventArgs $ args ) { $ this -> em = $ args -> getEntityManager ( ) ; $ this -> uow = $ this -> em -> getUnitOfWork ( ) ; $ this -> widgetRepo = $ this -> em -> getRepository ( 'Victoire\Bundle\WidgetBundle\Entity\Widget' ) ; $ this -> viewRepo = $ this -> em -> getRepository ( 'Victoire\Bundle\CoreBundle\Entity\View' ) ; $ updatedEntities = $ this -> uow -> getScheduledEntityUpdates ( ) ; $ deletedEntities = $ this -> uow -> getScheduledEntityDeletions ( ) ; //Update View's CSS and inheritors of updated and deleted widgets foreach ( array_merge ( $ updatedEntities , $ deletedEntities ) as $ entity ) { if ( ! ( $ entity instanceof Widget ) ) { continue ; } /* @var Widget $entity */ $ widgetMap = $ entity -> getWidgetMap ( ) ; if ( $ widgetMap -> getAction ( ) !== WidgetMap :: ACTION_DELETE ) { $ view = $ widgetMap -> getView ( ) ; if ( $ this -> em -> contains ( $ view ) ) { $ this -> updateViewCss ( $ view ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ view ) ; } } } //Remove CSS of deleted View and update its inheritors foreach ( $ deletedEntities as $ entity ) { if ( ! ( $ entity instanceof View ) ) { continue ; } $ this -> viewCssBuilder -> removeCssFile ( $ entity -> getCssHash ( ) ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ entity ) ; } //Update CSS of updated View and its inheritors foreach ( $ updatedEntities as $ entity ) { if ( ! ( $ entity instanceof View ) ) { continue ; } $ this -> updateViewCss ( $ entity ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ entity ) ; } $ this -> uow -> computeChangeSets ( ) ; }
Change cssHash of views when a widget is updated or deleted.

@param OnFlushEventArgs $args
Change cssHash of views when a widget is updated or deleted .