예제 #1
0
 /**
  * @Route("/", name="admin")
  * @Template()
  */
 public function adminAction()
 {
     $em = $this->getDoctrine()->getManager();
     $config = new Config($em, 'Appbundle\\Entity\\Category');
     $nsm = new Manager($config);
     //FOR GETTING TREE
     $rootNode = $nsm->fetchTree(15);
     /*$category = new Category();
       $category->setName('Obiloviny');
       $category->setUrlName('obiloviny');*/
     // FOR ADDING ROOT CATEGORY
     //$rootNode = $nsm->createRoot($category);
     // FOR ADDING CHILD
     //$rootNode->addChild($category);
     //$this->addFlash("success", "child node přidán");
     dump($nsm->fetchTreeAsArray(15));
     return ["tree" => $nsm->fetchTreeAsArray(15)];
 }
 private function getEntities()
 {
     $p = new Person('Sergio', 'Santoro');
     $entities[] = $p;
     $p = new Customer('Sergio', 'Lesta');
     $p->setShippingAddress('This is an address');
     $entities[] = $p;
     $p = new Employee('Sergio', 'Franchi');
     $p->setDepartement('machinery');
     $entities[] = $p;
     $p = new Engineer('Alberto', 'Grafi');
     $p->setDepartement('machinery');
     $p->setMainSkill('desing');
     $entities[] = $p;
     $p = new Manager('Sergio', 'Grafi');
     $p->setDepartement('recruiting');
     $p->setYearsOfExperience(5);
     $entities[] = $p;
     return $entities;
 }
예제 #3
0
 /**
  * @Route("/menuLiCategories", name="main_menuLiCategories")
  * @Template()
  */
 public function menuLiCategoriesAction()
 {
     $em = $this->getDoctrine()->getManager();
     $config = new Config($em);
     $nsm = new Manager($config);
     /* $categories = $this->getDoctrine()
        ->getRepository("AppBundle:Category")
        ->findBy(['parent' => null]); */
     $categories = array_merge($nsm->fetchTreeAsArray(13), $nsm->fetchTreeAsArray(15), $nsm->fetchTreeAsArray(16));
     return ['categories' => $categories];
 }
예제 #4
0
 public function load(ObjectManager $manager)
 {
     $role = new Role();
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setPassword('password');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setRole($role->getId('ADMIN'));
     $territory1 = new Territory();
     $territory1->setName("Округ1");
     $territory1->setKey("Описание");
     $territory2 = new Territory();
     $territory2->setName("Округ2");
     $territory2->setKey("Описание");
     $manager->persist($territory1);
     $manager->persist($territory2);
     $manager->persist($userAdmin);
     $userUser = new User();
     $userUser->setUsername('user');
     $userUser->setPassword('password');
     $userUser->setEmail('*****@*****.**');
     $userUser->setRole($role->getId('USER'));
     $manager->persist($userUser);
     $manager->flush();
     $userManager1 = new Manager();
     $userManager1->setUsername('manager1');
     $userManager1->setPassword('password');
     $userManager1->setEmail('*****@*****.**');
     $userManager1->setRole($role->getId('MANAGER'));
     $userManager1->setSurname('manager1');
     $userManager1->setName('manager1');
     $userManager1->setPatronymic('manager1');
     $userManager1->setGender('m');
     $userManager1->setBirthday(new \DateTime('1980-01-01'));
     $userManager2 = new Manager();
     $userManager2->setUsername('manager2');
     $userManager2->setPassword('password');
     $userManager2->setEmail('*****@*****.**');
     $userManager2->setRole($role->getId('MANAGER'));
     $userManager2->setSurname('manager2');
     $userManager2->setName('manager2');
     $userManager2->setPatronymic('manager2');
     $userManager2->setGender('m');
     $userManager2->setBirthday(new \DateTime('1980-01-01'));
     $manager->persist($userManager1);
     $manager->persist($userManager2);
     $userPresenter1 = new Presenter();
     $userPresenter1->setUsername('presenter1');
     $userPresenter1->setPassword('password1');
     $userPresenter1->setEmail('*****@*****.**');
     $userPresenter1->setRole($role->getId('PRESENTER'));
     $userPresenter1->setSurname('Иванов');
     $userPresenter1->setName('Иван');
     $userPresenter1->setPatronymic('Иванович');
     $userPresenter1->setGender('m');
     $userPresenter1->setBirthday(new \DateTime('1980-01-01'));
     $userPresenter1->setTerritory($territory1);
     $userPresenter1->setManager($userManager1);
     $userPresenter2 = new Presenter();
     $userPresenter2->setUsername('presenter2');
     $userPresenter2->setPassword('password2');
     $userPresenter2->setEmail('*****@*****.**');
     $userPresenter2->setRole($role->getId('PRESENTER'));
     $userPresenter2->setSurname('Петров');
     $userPresenter2->setName('Петр');
     $userPresenter2->setPatronymic('Петрович');
     $userPresenter2->setGender('m');
     $userPresenter2->setBirthday(new \DateTime('1980-01-01'));
     $userPresenter2->setManager($userManager2);
     $userPresenter2->setTerritory($territory2);
     $manager->persist($userPresenter1);
     $manager->persist($userPresenter2);
     $manager->flush();
 }
예제 #5
0
 /**
  * Creates a form to delete a User entity by id.
  *
  * @param mixed $id The entity id
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Manager $manager)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('managers_delete', array('id' => $manager->getId())))->setMethod('DELETE')->add('submit', 'submit', array('label' => 'Удалить менеджера', 'attr' => array('class' => 'btn btn-default btn-lg btn-block')))->getForm();
 }