Eccube\Controller\Admin\Setting\System\AuthorityController::index PHP Метод

index() публичный Метод

public index ( Application $app, Request $request )
$app Eccube\Application
$request Symfony\Component\HttpFoundation\Request
    public function index(Application $app, Request $request)
    {
        $AuthorityRoles = $app['eccube.repository.authority_role']->findAllSort();
        $builder = $app['form.factory']->createBuilder();
        $builder->add('AuthorityRoles', 'collection', array('type' => 'admin_authority_role', 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'data' => $AuthorityRoles));
        $event = new EventArgs(array('builder' => $builder, 'AuthorityRoles' => $AuthorityRoles), $request);
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_AUTHORITY_INDEX_INITIALIZE, $event);
        $form = $builder->getForm();
        if (count($AuthorityRoles) == 0) {
            // 1件もない場合、空行を追加
            $form->get('AuthorityRoles')->add(uniqid(), 'admin_authority_role');
        }
        if ('POST' === $request->getMethod()) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $data = $form->getData();
                foreach ($AuthorityRoles as $AuthorityRole) {
                    $app['orm.em']->remove($AuthorityRole);
                }
                foreach ($data['AuthorityRoles'] as $AuthorityRole) {
                    $Authority = $AuthorityRole->getAuthority();
                    $denyUrl = $AuthorityRole->getDenyUrl();
                    if ($Authority && !empty($denyUrl)) {
                        $app['orm.em']->persist($AuthorityRole);
                    } else {
                        $id = $AuthorityRole->getId();
                        if (!empty($id)) {
                            $role = $app['eccube.repository.authority_role']->find($id);
                            if ($role) {
                                // 削除
                                $app['orm.em']->remove($AuthorityRole);
                            }
                        }
                    }
                }
                $app['orm.em']->flush();
                $event = new EventArgs(array('form' => $form, 'AuthorityRoles' => $AuthorityRoles), $request);
                $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_AUTHORITY_INDEX_COMPLETE, $event);
                $app->addSuccess('admin.system.authority.save.complete', 'admin');
                return $app->redirect($app->url('admin_setting_system_authority'));
            }
        }
        return $app->render('Setting/System/authority.twig', array('form' => $form->createView()));
    }
AuthorityController