예제 #1
0
 /**
  * @Route("/department/{id}", name="app_department_show")
  * @Template()
  */
 public function showAction(Request $request, Department $department)
 {
     $lecturers = $department->getLecturers();
     $agroups = $department->getAgroups();
     $subjects = $department->getSubjects();
     return ['department' => $department, 'lecturers' => $lecturers, 'agroups' => $agroups, 'subjects' => $subjects];
 }
예제 #2
0
 public function testSetDepartment()
 {
     // new entity
     $semester = new Semester();
     // Dummy entity
     $department = new Department();
     $department->setName("NTNU");
     // Use the setDepartment method
     $semester->setDepartment($department);
     // Assert the result
     $this->assertEquals($department, $semester->getDepartment());
 }
예제 #3
0
 public function testSetDepartment()
 {
     // new entity
     $team = new Team();
     // dummy entity
     $department = new Department();
     $department->setName("NTNU");
     // Use the setDepartment method
     $team->setDepartment($department);
     // Assert the result
     $this->assertEquals($department, $team->getDepartment());
 }
 public function testSetDepartment()
 {
     // new entity
     $fos = new FieldOfStudy();
     // A new test department entity
     $department = new Department();
     $department->setName("NTNU");
     // Use the setDepartment method
     $fos->setDepartment($department);
     // Assert the result
     $this->assertEquals($department, $fos->getDepartment());
 }
예제 #5
0
 /**
  * @Route("/admin/department/new", name="department-add")
  * @param Request $request
  * @return string|\Symfony\Component\HttpFoundation\Response
  * @Method("POST")
  */
 public function departmentAddNewAction(Request $request)
 {
     //create new department
     $department = new Department();
     $department->setName($request->request->get('department_name'));
     $this->get('department_manager')->save($department);
     foreach ($request->get('users') as $userId) {
         $user = $this->get('user_repository')->findByPk($userId);
         $department->addEmployee($user);
     }
     $doctrine = $this->container->get('doctrine');
     $em = $doctrine->getManager();
     $em->flush();
     return $this->redirectToRoute('department-main');
 }
예제 #6
0
 /**
  * @dataProvider getValidTestData
  */
 public function testForm($data)
 {
     $type = new CreateDepartmentType();
     $form = $this->factory->create($type);
     $object = new Department();
     $object->fromArray($data);
     // submit the data to the form directly
     $form->submit($data);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($data) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
예제 #7
0
 public function contactAction(Request $request, Department $department)
 {
     $contact = new Contact();
     $contactForm = $this->createForm(new ContactType(), $contact, array('action' => $this->generateUrl('admission_contact', array('id' => $department->getId()))));
     // Get the sender email from the parameter file
     $fromEmail = $this->container->getParameter('no_reply_email_contact_form');
     $contactForm->handleRequest($request);
     if ($contactForm->isValid()) {
         //send mail to department
         $message = \Swift_Message::newInstance()->setSubject('Nytt kontaktskjema')->setFrom($fromEmail)->setTo($department->getEmail())->setBody($this->renderView('admission/contactEmail.txt.twig', array('contact' => $contact)));
         $this->get('mailer')->send($message);
         //send receipt mail back to sender
         $receipt = \Swift_Message::newInstance()->setSubject('Kvittering for kontaktskjema')->setFrom($fromEmail)->setTo($contact->getEmail())->setBody($this->renderView('admission/receiptEmail.txt.twig', array('contact' => $contact)));
         $this->get('mailer')->send($receipt);
         //popup text after completion
         $request->getSession()->getFlashBag()->add('contact-notice', 'Kontaktforespørsel sendt, takk for henvendelsen!');
         //redirect to avoid re-posting the form
         return $this->redirect($this->generateUrl('admission_show_specific_department', array('id' => $department->getId())));
     }
     return $this->render('admission/contact.html.twig', array('contactForm' => $contactForm->createView(), 'department' => $department));
 }
예제 #8
0
 public function testRemoveDepartment()
 {
     // new entity
     $school = new School();
     $department1 = new Department();
     $department1->setName("Department1");
     $department2 = new Department();
     $department2->setName("Department2");
     $department3 = new Department();
     $department3->setName("Department3");
     // Use the addDepartment method
     $school->addDepartment($department1);
     $school->addDepartment($department2);
     $school->addDepartment($department3);
     // Remove $department1
     $school->removeDepartment($department1);
     // Departments are stored in an array
     $departments = $school->getDepartments();
     // Loop through the array
     foreach ($departments as $d) {
         // Assert the result
         $this->assertNotEquals($department1, $d);
     }
 }
예제 #9
0
 public function load(ObjectManager $manager)
 {
     $department1 = new Department();
     $department1->setName('Norges teknisk-naturvitenskapelige universitet');
     $department1->setShortName('NTNU');
     $department1->setEmail('*****@*****.**');
     $department1->addSchool($this->getReference('school-1'));
     $department1->addSchool($this->getReference('school-2'));
     $department1->addSchool($this->getReference('school-3'));
     $department1->setAddress('Høgskoleringen 5 7491 Trondheim');
     $manager->persist($department1);
     $department2 = new Department();
     $department2->setName('Høgskolen i Sør-Trønderlag');
     $department2->setShortName('HiST');
     $department2->setEmail('*****@*****.**');
     $department2->addSchool($this->getReference('school-2'));
     $department2->setAddress('*hist adresse*');
     $manager->persist($department2);
     $department3 = new Department();
     $department3->setName('Norges miljø- og biovitenskapelige universitet');
     $department3->setShortName('NMBU');
     $department3->setEmail('*****@*****.**');
     $department3->addSchool($this->getReference('school-1'));
     $department3->setAddress('*NMBU adresse*');
     $manager->persist($department3);
     $department4 = new Department();
     $department4->setName('Universitetet i Oslo');
     $department4->setShortName('UiO');
     $department4->setEmail('*****@*****.**');
     $department4->addSchool($this->getReference('school-2'));
     $department4->setAddress('*UiO adresse*');
     $manager->persist($department4);
     $manager->flush();
     $this->addReference('dep-1', $department1);
     $this->addReference('dep-2', $department2);
     $this->addReference('dep-3', $department3);
     $this->addReference('dep-4', $department4);
 }
예제 #10
0
 /**
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  * @Route("/users/newGroup/compete", name="newGroup")
  */
 public function newDepartmentAction(Request $request)
 {
     $department = new Department();
     $department->setName($request->get('_name'));
     $department->setCompany($this->getDoctrine()->getRepository('AppBundle:Company')->find($request->get('_company')));
     $em = $this->getDoctrine()->getManager();
     $em->persist($department);
     $em->flush();
     return $this->redirectToRoute('adminPage');
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $stepDept = new Department();
     $stepDept->setName('Home');
     $stepDept->setOffice($this->getReference('stepOffice'));
     $manager->persist($stepDept);
     $oneOne = new Department();
     $oneOne->setName('ONE-DeptOne');
     $oneOne->setOffice($this->getReference('officeOne'));
     $manager->persist($oneOne);
     $oneTwo = new Department();
     $oneTwo->setName('ONE-DeptTwo');
     $oneTwo->setOffice($this->getReference('officeOne'));
     $manager->persist($oneTwo);
     $oneThree = new Department();
     $oneThree->setName('ONE-DeptThree');
     $oneThree->setOffice($this->getReference('officeOne'));
     $manager->persist($oneThree);
     $twoOne = new Department();
     $twoOne->setName('TWO-DeptOne');
     $twoOne->setOffice($this->getReference('officeTwo'));
     $manager->persist($twoOne);
     $twoTwo = new Department();
     $twoTwo->setName('TWO-DeptTwo');
     $twoTwo->setOffice($this->getReference('officeTwo'));
     $manager->persist($twoTwo);
     $manager->flush();
     $aclProvider = $this->container->get('security.acl.provider');
     $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
     $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
     $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
     $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
     $objectIdentity = ObjectIdentity::fromDomainObject($stepDept);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($oneOne);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($oneTwo);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($oneThree);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($leadRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($twoOne);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($twoTwo);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $this->addReference('stepDept', $stepDept);
     $this->addReference('oneOne', $oneOne);
     $this->addReference('oneTwo', $oneTwo);
     $this->addReference('oneThree', $oneThree);
     $this->addReference('twoOne', $twoOne);
     $this->addReference('twoTwo', $twoTwo);
 }
예제 #12
0
 public function testRemoveTeam()
 {
     // new entity
     $department = new Department();
     $team1 = new Team();
     $team1->setName("Team1");
     $team2 = new Team();
     $team2->setName("Team2");
     $team3 = new Team();
     $team3->setName("Team3");
     // Use the addTeam method
     $department->addTeam($team1);
     $department->addTeam($team2);
     $department->addTeam($team3);
     // Remove $team1 from department
     $department->removeTeam($team1);
     // Teams are stored in an array
     $teams = $department->getTeams();
     // Loop through the array
     foreach ($teams as $team) {
         // Assert the result
         $this->assertNotEquals($team1, $team);
     }
 }
예제 #13
0
 public function __construct(Department $department, $authenticated)
 {
     $this->departmentId = $department->getId();
     $this->authenticated = $authenticated;
 }
예제 #14
0
 /**
  * @Route("/subject/{id}/add-lecturer/{ }", name="add_lecturer_to_subject")
  * @Template()
  */
 public function addLecturerToSubjectAction(Request $request, Department $department)
 {
     $lecturers = $department->getLecturers();
     return ['lecturers' => $lecturers];
 }