Beispiel #1
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $module = $input->getArgument('module');
     $path = "{$this->libsDir}/venne/{$module}-module";
     if (!file_exists($path)) {
         $output->writeln("<error>Path '" . $path . "' does not exist.</error>");
         return;
     }
     \Venne\Utils\File::rmdir($path, TRUE);
 }
Beispiel #2
0
 public function cleanSessions()
 {
     foreach (Finder::find('*')->in($this->sessionsDir) as $file) {
         $path = $file->getPathname();
         if (is_dir($path)) {
             File::rmdir($path, TRUE);
         } else {
             unlink($path);
         }
     }
 }
Beispiel #3
0
 public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     // Application
     $container->getDefinition('nette.presenterFactory')->setClass('Venne\\Application\\PresenterFactory', array(isset($container->parameters['appDir']) ? $container->parameters['appDir'] : NULL));
     $container->addDefinition($this->prefix('controlVerifier'))->setClass('Venne\\Security\\ControlVerifiers\\ControlVerifier');
     $container->addDefinition($this->prefix('controlVerifierReader'))->setClass('Venne\\Security\\ControlVerifierReaders\\AnnotationReader');
     $container->getDefinition('user')->setClass('Venne\\Security\\User');
     // cache
     $container->addDefinition($this->prefix('cacheManager'))->setClass('Venne\\Caching\\CacheManager', array('@cacheStorage', '%tempDir%/cache', '%tempDir%/sessions'));
     // http
     $container->getDefinition('httpResponse')->addSetup('setHeader', array('X-Powered-By', 'Nette Framework && Venne:Framework'));
     // session
     $session = $container->getDefinition('session');
     foreach ($config['session'] as $key => $val) {
         if ($val) {
             $session->addSetup('set' . ucfirst($key), $val);
         }
     }
     // template
     $container->getDefinition('nette.latte')->setClass('Venne\\Latte\\Engine')->addSetup('$m = Venne\\Latte\\Macros\\UIMacros::install(?->compiler); $m->injectHelper(?)', array('@self', '@venne.moduleHelpers'))->setShared(FALSE);
     $container->addDefinition($this->prefix("templateConfigurator"))->setClass("Venne\\Templating\\TemplateConfigurator", array('@container', '@nette.latteFactory'));
     // helpers
     $container->addDefinition($this->prefix("helpers"))->setClass("Venne\\Templating\\Helpers");
     // modules
     $container->addDefinition($this->prefix('moduleManager'))->setClass('Venne\\Module\\ModuleManager', array('@container', '@venne.cacheManager', '%libsDir%', '%configDir%', '%modulesDir%'));
     $container->addDefinition($this->prefix('templateManager'))->setClass('Venne\\Module\\TemplateManager', array('%modules%'));
     // widgets
     $container->addDefinition($this->prefix('widgetManager'))->setClass('Venne\\Widget\\WidgetManager');
     // CLI
     $cliRoute = $container->addDefinition($this->prefix("CliRoute"))->setClass("Venne\\Application\\Routers\\CliRouter")->setAutowired(FALSE);
     $container->getDefinition('router')->addSetup('offsetSet', array(NULL, $cliRoute));
     // Commands
     $commands = array('cache' => 'Venne\\Caching\\Commands\\Cache', 'moduleUpdate' => 'Venne\\Module\\Commands\\Update', 'moduleInstall' => 'Venne\\Module\\Commands\\Install', 'moduleUninstall' => 'Venne\\Module\\Commands\\Uninstall', 'moduleUpgrade' => 'Venne\\Module\\Commands\\Upgrade', 'moduleRegister' => 'Venne\\Module\\Commands\\Register', 'moduleUnregister' => 'Venne\\Module\\Commands\\Unregister', 'moduleList' => 'Venne\\Module\\Commands\\List', 'moduleCreate' => 'Venne\\Module\\Commands\\Create', 'moduleDelete' => 'Venne\\Module\\Commands\\Delete');
     foreach ($commands as $name => $cmd) {
         $container->addDefinition($this->prefix(lcfirst($name) . 'Command'))->setClass("{$cmd}Command")->addTag('command');
     }
     // helpers
     $container->addDefinition($this->prefix('moduleHelpers'))->setClass('Venne\\Module\\Helpers', array('%modules%'));
     // symlink to client-side
     $clientSidePath = realpath($container->parameters['libsDir'] . '/nette/nette/client-side');
     $netteModulePath = $container->parameters['resourcesDir'] . '/netteModule';
     if (!file_exists($netteModulePath) && file_exists($clientSidePath)) {
         umask(00);
         @mkdir(dirname($netteModulePath), 0777, TRUE);
         if (!@symlink(File::getRelativePath(dirname($netteModulePath), $clientSidePath), $netteModulePath) && !file_exists($netteModulePath)) {
             File::copy($clientSidePath, $netteModulePath);
         }
     }
 }
Beispiel #4
0
 /**
  * @secured(privilege="remove")
  */
 public function handleDelete($key)
 {
     $path = $this->moduleHelpers->expandPath($key, 'Resources/layouts');
     unlink($path);
     if (substr($path, -14) === '/@layout.latte') {
         File::rmdir(dirname($path), TRUE);
         $this->flashMessage($this->translator->translate('Layout has been removed.'), 'success');
     } else {
         $this->flashMessage($this->translator->translate('Template has been removed.'), 'success');
     }
     if (!$this->isAjax()) {
         $this->redirect('this', array('key' => NULL));
     }
     $this->invalidateControl('content');
     $this['panel']->invalidateControl('content');
     $this->payload->url = $this->link('this', array('key' => NULL));
 }
Beispiel #5
0
 /**
  * @param \Venne\Module\IModule $module
  */
 public function uninstall(IModule $module)
 {
     $name = $module->getName();
     $configuration = $module->getConfiguration();
     // update main config.neon
     if (count($configuration) > 0) {
         $orig = $data = $this->loadConfig();
         $data = $this->getRecursiveDiff($data, $configuration);
         // remove extension parameters
         $configuration = $module->getConfiguration();
         if (isset($configuration['extensions'])) {
             foreach ($configuration['extensions'] as $key => $values) {
                 if (isset($data[$key])) {
                     unset($data[$key]);
                 }
             }
         }
         $this->saveConfig($data);
         $this->actions[] = function ($self) use($orig) {
             $self->saveConfig($orig);
         };
     }
     // remove resources dir
     $resourcesDir = $this->resourcesDir . "/{$name}Module";
     if (file_exists($resourcesDir)) {
         if (is_link($resourcesDir)) {
             unlink($resourcesDir);
         } else {
             File::rmdir($resourcesDir, TRUE);
         }
     }
 }