/** * Called on the prePersist event. * * @param LifecycleEventArgs $eventArgs */ public function prePersist(LifecycleEventArgs $eventArgs) { $object = $eventArgs->getObject(); // only handle our model if (!$object instanceof Group) { return; } $categories = [$object->getFrontendUserCategory(), $object->getFrontendModCategory(), $object->getACPCategory()]; $topLevelCategory = new OptionCategory(); $topLevelCategory->setCategories($categories); $this->groupService->setOptionsFor($object->getRoleName(), $topLevelCategory); }
/** * Tests that options can be removed. */ public function testRemoval() { $this->groupService->setOptionsFor('ADMIN', $this->optionData['admin']); $options = $this->groupService->getOptionsFor('ADMIN'); $this->assertEquals($this->optionData['admin'], $options); $this->groupService->removeOptionsFor('ADMIN'); try { $this->groupService->getOptionsFor('ADMIN'); $this->fail(); } catch (\Exception $e) { $this->assertTrue(true); } }