protected function processForm(ModelInterface $entity, array $parameters, $method = 'PUT') { /** * @var TutorialInterface $entity */ if (null === $entity->getAuthor()) { $entity->setAuthor($this->getUserRole()); } return parent::processForm($entity, $parameters, $method); }
/** * @param ModelInterface $entity * @return void */ public function save(ModelInterface $entity) { if (!$entity instanceof CourseInterface) { throw new InvalidArgumentException('expect an CourseInterface object'); } $hashTag = $entity->getHashTag(); $course = $this->repository->getCourseByHashTag($hashTag); if ($course instanceof CourseInterface) { $entity->setHashTag($hashTag . uniqid("", true)); } $this->em->persist($entity); $this->em->flush(); }