Exemplo n.º 1
0
 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 1; $i <= 2; $i++) {
         $menuItem = new MenuItem();
         $menuItem->setTitle($faker->word);
         $menuItem->setDescription($faker->text());
         $manager->persist($menuItem);
     }
     $manager->flush();
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $refs = $this->referenceRepository->getReferences();
     $orgRefNames = [];
     $deptRefNames = [];
     $linkRefNames = [];
     foreach ($refs as $ref) {
         $refNames = $this->referenceRepository->getReferenceNames($ref);
         if (is_a($ref, 'AppBundle\\Entity\\Department')) {
             $deptRefNames[] = $refNames[0];
         }
         if (is_a($ref, 'AppBundle\\Entity\\MenuLink')) {
             $linkRefNames[] = $refNames[0];
         }
     }
     $items = [];
     foreach ($deptRefNames as $deptRefName) {
         $i = 1;
         $department = $this->getReference($deptRefName);
         foreach ($linkRefNames as $linkRefName) {
             $item = new MenuItem();
             $item->isActive(true);
             $item->setPosition($i);
             $item->setMenuLink($this->getReference($linkRefName));
             $item->setOrganization($department->getOffice()->getOrganization());
             if (in_array($linkRefName, ['inventoryAuditLink', 'inventoryActionLink', 'inventoryLogLink'])) {
                 $item->setParent($items[$deptRefName]['mainLink']);
             } else {
                 if (in_array($linkRefName, ['adminInventoryLink', 'adminAccountingLink'])) {
                     $item->setParent($items[$deptRefName]['adminLink']);
                 } else {
                     $item->setDepartment($department);
                 }
             }
             $manager->persist($item);
             $items[$deptRefName][$linkRefName] = $item;
             $i++;
         }
     }
     $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');
     foreach ($items as $deptItems) {
         foreach ($deptItems as $item) {
             $objectIdentity = ObjectIdentity::fromDomainObject($item);
             $acl = $aclProvider->createAcl($objectIdentity);
             $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
             $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
             $aclProvider->updateAcl($acl);
         }
     }
 }
Exemplo n.º 3
0
 public function testSubmitValidData()
 {
     $formData = array('title' => 'Test title', 'description' => 'Test description');
     $form = $this->factory->create(MenuItemType::class);
     $object = new MenuItem();
     $object->setTitle('Test title');
     $object->setDescription('Test description');
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Exemplo n.º 4
0
 /**
  * Add child
  *
  * @param \AppBundle\Entity\MenuItem $menuItem
  * @return Department
  */
 public function addChild(MenuItem $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Add menuItems
  *
  * @param \AppBundle\Entity\MenuItem $menuItem
  * @return Department
  */
 public function addMenuItem(\AppBundle\Entity\MenuItem $menuItem)
 {
     $this->menuItems[] = $menuItem;
     $menuItem->setDepartment($this);
     return $this;
 }
 private function deleteForm(MenuItem $menuItem)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_menu_item_delete', array('id' => $menuItem->getId())))->setMethod('DELETE')->getForm();
 }