5

我正在使用奏鸣曲管理员。我有两个实体:假期条目 + 员工假期条目 (1:m)

在我的假期条目管理课程中:

  • 用户选择我想要休假的员工(从多对多关系)。
  • 通过 Employee Vacation Entry 实体对每个员工进行验证。

    class VacationEntryAdmin extends Admin {
    
        // some 
        // content
        public function prePersist($cv)
        {
            // some 
            // content
            $validator = $this->getValidator();
            $errors = $validator->validate($employeeVacationEntry);
            if (count($errors) > 0) {
                foreach ($errors as $error) {
                    $errorsString = $error->getMessage();
                    $employeeName = $error->getRoot()->getEmployee()->getName();
                    $this->getRequest()->getSession()->getFlashBag()->add("danger", $employeeName . ': ' . $errorsString);
                }    //I'd like to stop the persistence of all the Vacation Entry here.
            }
            $em->persist($employeeVacationEntry);
        }
    
    }
    
4

0 回答 0