public function publishUnpublish($id,
        User $userEntity
    )
    {
        if ($id === null) {
            throw new ItemNotSelectedException;
        }
        $entity = $this->getById($id);
        $entity->published = !$entity->published;
        $entity->modifiedOn = new DateTime();
        $entity->modifiedBy = $userEntity;
        $this->repository->saveItem($entity);
    }
public function publishUnpublish($id,
        User $userEntity
    )
    {
        if ($id === null) {
            throw new ItemNotSelectedException;
        }
        $entity = $this->getById($id);
        $entity->published = !$entity->published;
        $entity->modifiedOn = new DateTime();
        $entity->modifiedBy = $userEntity;
        $this->repository->saveItem($entity);
    }
public function publishUnpublish ( $ id , User $ userEntity ) { if ( $ id === null ) { throw new ItemNotSelectedException ; } $ entity = $ this -> getById ( $ id ) ; $ entity -> published = ! $ entity -> published ; $ entity -> modifiedOn = new DateTime ( ) ; $ entity -> modifiedBy = $ userEntity ; $ this -> repository -> saveItem ( $ entity ) ; }
Method for publishing and unpublishing entity
@param integer $id
@param User $userEntity
@throws ItemNotSelectedException
Method for publishing and unpublishing entity