Exemplo n.º 1
0
 public function onUpdate(Controller $controller, Request $request, ActionCache $action, $page, Form $form)
 {
     if ($page->admin_entity_id && $this->admin_loader->hasAdminClass($page->admin_class)) {
         $admin = $this->admin_loader->getAdminByClass($page->admin_class);
         $object = $admin->getObjectById($page->admin_entity_id);
         if ($object) {
             $_page = $admin->getReflectionProperty($admin->property_page_name)->getValue($object);
             if ($_page !== $page) {
                 throw new \Exception("bigger error");
             }
             $has_changed = false;
             $config = $admin->copy_properties[$admin->property_page_name];
             foreach ($config as $object_property => $page_property) {
                 $page_value = $this->getReflectionProperty($page_property)->getValue($page);
                 $object_value = $admin->getReflectionProperty($object_property)->getValue($object);
                 if ($object_value !== $page_value) {
                     $admin->getReflectionProperty($object_property)->setValue($object, $page_value);
                     $has_changed = true;
                 }
             }
             if ($has_changed) {
                 $em = $admin->getManager();
                 $em->persist($object);
             }
         }
     }
     parent::onUpdate($controller, $request, $action, $page, $form);
 }
Exemplo n.º 2
0
 public function onUpdate(Controller $controller, Request $request, ActionCache $action, $menu, Form $form)
 {
     if (!$menu->menu_group) {
         throw new \Exception('menu no group');
     }
     $menu->menu_group->updated = new \DateTime('now');
     $this->getManager()->persist($menu->menu_group);
     parent::onUpdate($controller, $request, $action, $menu, $form);
 }
Exemplo n.º 3
0
 public function onUpdate(Controller $controller, Request $request, ActionCache $action, $object, Form $form)
 {
     if ($object->default_group || $object->trust_group) {
         $roles = $this->admin_loader->getRoleHierarchy();
         foreach ($object->getRoles() as $role) {
             if ('ROLE_ADMIN' === $role || isset($roles[$role]) && in_array('ROLE_ADMIN', $roles[$role])) {
                 $form->addError(new \Symfony\Component\Form\FormError($this->trans(".form.default_group.no_admin")));
                 return;
             }
         }
         if ($object->hasRole('ROLE_ADMIN')) {
         }
         if ($object->default_group && $object->trust_group) {
             $form->addError(new \Symfony\Component\Form\FormError($this->trans(".form.default_group.trust_default_conflict")));
             return;
         }
         $em = $this->getManager();
         $repo = $this->getRepository();
         $groups = $repo->findAll();
         foreach ($groups as $group) {
             if ($group->isEqual($object)) {
                 continue;
             }
             if ($object->default_group) {
                 if ($group->default_group) {
                     $group->default_group = false;
                     $em->persist($group);
                 }
             }
             if ($object->trust_group) {
                 if ($group->trust_group) {
                     $group->trust_group = false;
                     $em->persist($group);
                 }
             }
         }
     }
     parent::onUpdate($controller, $request, $action, $object, $form);
 }
Exemplo n.º 4
0
 public function onUpdate(Controller $controller, Request $request, ActionCache $action, $menu, Form $form)
 {
     parent::onUpdate($controller, $request, $action, $menu, $form);
 }