/** * @param \Nette\DI\Container * @param array */ public function __construct(DI\Container $context, array $configuration = array()) { $this->context = $context; $this->configuration = \Nette\Utils\Arrays::mergeTree(array( 'productionMode' => $context->params['productionMode'], 'proxyDir' => $context->expand("%appDir%/proxies"), 'proxyNamespace' => 'App\Models\Proxies', 'entityDirs' => array($context->params['appDir'], NELLA_FRAMEWORK_DIR), 'migrations' => array( 'name' => \Nella\Framework::NAME . " DB Migrations", 'table' => "db_version", 'directory' => $context->expand("%appDir%/migrations"), 'namespace' => 'App\Models\Migrations', ) ), $configuration); }
/** * @param \Venne\Module\IModule $module * @return array * @throws \Exception */ protected function getAllClasses() { // find files $robotLoader = new \Nette\Loaders\RobotLoader(); $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage()); foreach ($this->context->parameters['modules'] as $name => $item) { if ($item[ModuleManager::MODULE_STATUS] === ModuleManager::STATUS_INSTALLED) { $path = $this->context->expand($item[ModuleManager::MODULE_PATH]) . '/' . ucfirst($name) . 'Module'; if (file_exists($path)) { $robotLoader->addDirectory($path); } } } $robotLoader->register(); $entities = $robotLoader->getIndexedClasses(); // classes $classes = array(); foreach ($entities as $class => $item) { if (\Nette\Reflection\ClassType::from('\\' . $class)->hasAnnotation('ORM\\Entity')) { $classes[] = $class; } } $robotLoader->unregister(); return $classes; }
/** * @param Container $container * @param EntityManager $entityManager */ public function __construct(Container $container, EntityManager $entityManager) { parent::__construct('dwarfSearch:import'); $this->entityManager = $entityManager; $this->seasonsRepository = $entityManager->getRepository(Season::class); $this->episodesRepository = $entityManager->getRepository(Episode::class); $this->languagesRepository = $entityManager->getRepository(Language::class); $this->charactersRepository = $entityManager->getRepository(Character::class); $this->scenariosDir = $container->expand('%appDir%/../scenarios'); }
protected function validate(InputInterface $input, OutputInterface $output) { if (!in_array($this->outputFormat = trim($input->getOption('output-format'), '='), $formats = $this->writer->getFormats(), TRUE)) { $output->writeln('<error>Unknown --output-format</error>'); $output->writeln(sprintf("<info>Choose one of: %s</info>", implode(', ', $formats))); return FALSE; } $this->scanDirs = $this->serviceLocator->expand($input->getOption('scan-dir')); foreach ($this->scanDirs as $dir) { if (!is_dir($dir)) { $output->writeln(sprintf('<error>Given --scan-dir "%s" does not exists.</error>', $dir)); return FALSE; } } if (!is_dir($this->outputDir = $this->serviceLocator->expand($input->getOption('output-dir'))) || !is_writable($this->outputDir)) { $output->writeln(sprintf('<error>Given --output-dir "%s" does not exists or is not writable.</error>', $this->outputDir)); return FALSE; } return TRUE; }
/** * @return array */ protected function getModulesForUnregister() { $ret = array(); foreach ($this->modules as $name => $args) { $path = $this->context->expand($args[self::MODULE_PATH]); if (!file_exists($path)) { $ret[$name] = $args; } } return $ret; }
public function boot(Nette\DI\Container $container, $databaseName) { $this->windows = array(); $this->waitForSeleniumSlot(); $this->serviceLocator = $container; TesterHelpers::setup(); // ensure error & exception helpers are registered $this->httpServer = new HttpServer(); $env = (array) $this->options[self::OPTION_ENV_VARIABLES] + array($this->options[self::OPTION_ENV_PREFIX] . '_DEBUG' => '0', $this->options[self::OPTION_ENV_PREFIX] . '_SELENIUM' => '1', $this->options[self::OPTION_ENV_PREFIX] . '_DATABASE' => $databaseName, $this->options[self::OPTION_ENV_PREFIX] . '_LOG_DIR' => TEMP_DIR, $this->options[self::OPTION_ENV_PREFIX] . '_TEMP_DIR' => TEMP_DIR); $this->httpServer->start($this->serviceLocator->expand($this->options[self::OPTION_ROUTER]), $env); $httpRequest = new Nette\Http\Request($this->httpServer->getUrl(), array(), array(), array(), array(), array(), 'GET'); $this->serviceLocator->removeService('httpRequest'); $this->serviceLocator->addService('httpRequest', $httpRequest); $this->sessionFactory = new SessionFactory($this->serviceLocator, $this->httpServer, $this->options); $this->currentSession = $this->sessionFactory->create(); $this->currentSession->setContext($this); $this->windows[] = $this->currentSession; if ($this->options[self::OPTION_VIDEO_ENABLE]) { $this->videoRecorder = new VideoRecorder(TEMP_DIR); $this->videoRecorder->start(); } }
public static function preloadEnvironment(DI\Container $container) { $code = ''; $dir = $container->expand('%tempDir%/cache'); umask(00); @mkdir($dir, 0777); // @ - directory may exists // checks whether directory is writable $uniq = uniqid('_', TRUE); umask(00); if (!@mkdir("{$dir}/{$uniq}", 0777)) { // @ - is escalated to exception throw new Nette\InvalidStateException("Unable to write to directory '{$dir}'. Make this directory writable."); } // tests subdirectory mode $useDirs = @file_put_contents("{$dir}/{$uniq}/_", '') !== FALSE; // @ - error is expected @unlink("{$dir}/{$uniq}/_"); @rmdir("{$dir}/{$uniq}"); // @ - directory may not already exist $code .= self::generateCode('Nette\\Caching\\Storages\\FileStorage::$useDirectories = ?', $useDirs); return $code; }
static function preloadEnvironment(DI\Container $container) { $code = ''; $dir = $container->expand('%tempDir%/cache'); umask(00); @mkdir($dir, 0777); $uniq = uniqid('_', TRUE); umask(00); if (!@mkdir("{$dir}/{$uniq}", 0777)) { throw new Nette\InvalidStateException("Unable to write to directory '{$dir}'. Make this directory writable."); } $useDirs = @file_put_contents("{$dir}/{$uniq}/_", '') !== FALSE; @unlink("{$dir}/{$uniq}/_"); @rmdir("{$dir}/{$uniq}"); $code .= self::generateCode('Nette\\Caching\\Storages\\FileStorage::$useDirectories = ?', $useDirs); return $code; }