Exemplo n.º 1
0
 public function deleteAction(Application $app, Request $request, $accountName, $spaceName, $permissionId)
 {
     $space = $app->getSpaceRepository()->findByNameAndAccountName($spaceName, $accountName);
     if ($space) {
         $app->getPermissionRepository()->remove($app->getPermissionRepository()->find($permissionId));
     }
     return $app->redirect($app['url_generator']->generate('permission_index', array('accountName' => $accountName, 'spaceName' => $spaceName)));
 }
Exemplo n.º 2
0
 protected function configureTemplateEngine()
 {
     $this['twig.loader.filesystem']->addPath($this->getThemePath(true), 'BaseTheme');
     $path = $this->getThemePath(false);
     if (file_exists($path)) {
         $this['twig.loader.filesystem']->addPath($path, 'Theme');
     }
     $path = $this->getRootPath() . '/themes/fqdn';
     if (file_exists($path)) {
         $this['twig.loader.filesystem']->addPath($path, 'FqdnTheme');
     }
     $this['twig.loader.filesystem']->addPath(sprintf('%s/../../templates', __DIR__), 'BaseTemplates');
     $this['twig.loader.filesystem']->addPath(sprintf('%s/templates', $this->getRootPath()), 'Templates');
     // JF & HL: decide not to use this coz
     // 1. hardly ever useful
     // 2. breaks the loading order of routes and template engine
     // $this['twig']->addGlobal('main_menu', $this->buildMenu($this));
     $this['twig']->addGlobal('app_name', $this['app']['name']);
     // $this['twig']->addGlobal('spaceConfig', $this->getSpaceConfig());
     // Define userbaseUrl in twig templates for login + signup links
     if (isset($this['userbaseUrl'])) {
         $this['twig']->addGlobal('userbaseUrl', $this['userbaseUrl']);
     }
     if (isset($this['parameters']['userbase_url'])) {
         $this['twig']->addGlobal('userbase_url', $this['parameters']['userbase_url']);
     }
     $this['twig']->getExtension('core')->setDateFormat('Y-m-d', '%d days');
     if (!is_null($this->getFormat('date'))) {
         $this['twig']->getExtension('core')->setDateFormat($this->getFormat('date'), '%d days');
     }
     $app = $this;
     $this['twig']->addFilter(new \Twig_SimpleFilter('rdate', function ($date, $forceFormat = null) use($app) {
         return \Radvance\Framework\BaseWebApplication::rDateTime($date, $forceFormat ?: $app->getFormat('date') ?: 'Y-m-d');
     }));
     $this['twig']->addFilter(new \Twig_SimpleFilter('rtime', function ($date, $forceFormat = null) use($app) {
         return \Radvance\Framework\BaseWebApplication::rDateTime($date, $forceFormat ?: $app->getFormat('time') ?: 'H:i');
     }));
     $this['twig']->addFilter(new \Twig_SimpleFilter('rdatetime', function ($date, $forceFormat = null) use($app) {
         return \Radvance\Framework\BaseWebApplication::rDateTime($date, $forceFormat ?: $app->getFormat('datetime') ?: 'Y-m-d H:i');
     }));
     $app = $this;
     $app->before(function (Request $request, SilexApplication $app) {
         $this['twig']->addExtension(new \Radvance\Twig\TranslateExtension($request, $app));
     });
 }