/** * IDがnullの場合はpersist、そうでない場合はmergeを実行します。 * * @param AbstractEntityDB $entity */ public function save(AbstractEntityDB $entity) { if (is_null($entity->getId())) { $this->persist($entity); } else { $this->merge($entity); } }