public function addAction()
 {
     $form = new ProfessorForm($this->getEntityManager());
     $form->get('submit')->setAttribute('label', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $professor = new Professor();
         $form->setInputFilter($professor->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $professor->populate($form->getData());
             $jaTemEsteProfessor = $this->getEntityManager()->getRepository('Professor\\Entity\\Professor')->findBy(array('matriculaprofessor' => $professor->getMatriculaprofessor()));
             if ($jaTemEsteProfessor) {
                 $mensagem = 'Professor já cadastrado.';
                 return array('form' => $form, 'mensagem' => $mensagem);
             }
             //SET DATA NASC
             $data = explode("/", $professor->getDataNasc());
             $data = $data['0'] . "-" . $data['1'] . "-" . $data['2'];
             $professor->setDatanasc(new \DateTime($data));
             //END SET DATA NASC
             $departamento = $this->getEntityManager()->getRepository('Professor\\Entity\\Departamento')->findOneBy(array('iddepartamento' => $professor->getDepartamentodepartamento()));
             $professor->setDepartamentodepartamento($departamento);
             $curso = $this->getEntityManager()->getRepository('Curso\\Entity\\Curso')->findOneBy(array('idcurso' => $professor->getCursoProfessor()));
             $professor->setCursoProfessor($curso);
             //var_dump($album->getDepartamentodepartamento()->getIddepartamento());exit;
             $this->getEntityManager()->persist($professor);
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('professor');
         }
     }
     return array('form' => $form);
 }
 /**
  * {@inheritDoc}
  */
 public function setCursoProfessor(\Curso\Entity\Curso $cursoProfessor = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCursoProfessor', array($cursoProfessor));
     return parent::setCursoProfessor($cursoProfessor);
 }