public function onPostUpdate(PostEvent $event)
 {
     $this->em = $event->getEntityManager();
     /** @var Post $entity */
     $entity = $event->getEntity();
     $uow = $this->em->getUnitOfWork();
     $uow->computeChangeSet($this->em->getClassMetadata(get_class($entity)), $entity);
     $changeSet = $uow->getEntityChangeSet($entity);
     if (!isset($changeSet['tags'])) {
         return;
     }
     if (isset($changeSet['status'])) {
         $oldStatus = $changeSet['status'][0];
         $newStatus = $changeSet['status'][1];
     } else {
         $oldStatus = $newStatus = $entity->getStatus();
     }
     $oldTags = $changeSet['tags'][0];
     $oldTagsArray = $entity->getTagsArray($oldTags);
     $newTags = $changeSet['tags'][1];
     $newTagsArray = $entity->getTagsArray($newTags);
     if ($newStatus && $newStatus == $oldStatus) {
         $this->addTags(array_values(array_diff($newTagsArray, $oldTagsArray)));
         $this->removeTags(array_values(array_diff($oldTagsArray, $newTagsArray)));
     } elseif ($newStatus && !$oldStatus) {
         $this->addTags(array_values($newTagsArray));
     } elseif (!$newStatus && $oldStatus) {
         $this->removeTags(array_values($oldTagsArray));
     }
 }
 public function onPostModify(PostEvent $event)
 {
     $this->handleMarkdown($event->getEntity());
 }