/**
  * Save an entity
  *
  * @param EntityInterface $entity
  *
  * @return bool
  */
 public function saveEntity(EntityInterface $entity)
 {
     $checkEntity = $this->getTable()->fetchEntityById($entity->getIdentifier());
     if ($checkEntity) {
         return $this->getTable()->updateEntity($entity);
     } else {
         return $this->getTable()->insertEntity($entity);
     }
 }
 /**
  * Delete an existing entity
  *
  * @param EntityInterface $entity
  *
  * @return bool
  */
 public function deleteEntity(EntityInterface $entity)
 {
     $delete = $this->getSql()->delete();
     $delete->where->equalTo($this->getPrimaryKey(), $entity->getIdentifier());
     try {
         $this->deleteWith($delete);
     } catch (RuntimeException $e) {
         return false;
     }
     return true;
 }