public function switchPublicationState(Post $post)
    {
        if (!$post->isPublished()) {
            $post->publish();
        } else {
            $post->unpublish();
        }

        $this->om->flush();

        $unitOfWork = $this->om->getUnitOfWork();
        $unitOfWork->computeChangeSets();
        $changeSet = $unitOfWork->getEntityChangeSet($post);

        $this->trackingManager->dispatchPostUpdateEvent($post, $changeSet);

        return $post;
    }
public function switchPublicationState(Post $post)
    {
        if (!$post->isPublished()) {
            $post->publish();
        } else {
            $post->unpublish();
        }

        $this->om->flush();

        $unitOfWork = $this->om->getUnitOfWork();
        $unitOfWork->computeChangeSets();
        $changeSet = $unitOfWork->getEntityChangeSet($post);

        $this->trackingManager->dispatchPostUpdateEvent($post, $changeSet);

        return $post;
    }
public function switchPublicationState ( Post $ post ) { if ( ! $ post -> isPublished ( ) ) { $ post -> publish ( ) ; } else { $ post -> unpublish ( ) ; } $ this -> om -> flush ( ) ; $ unitOfWork = $ this -> om -> getUnitOfWork ( ) ; $ unitOfWork -> computeChangeSets ( ) ; $ changeSet = $ unitOfWork -> getEntityChangeSet ( $ post ) ; $ this -> trackingManager -> dispatchPostUpdateEvent ( $ post , $ changeSet ) ; return $ post ; }
Switch post state.

@param Post $post
@param User $user
Switch post state .