public static function tearDownAfterClass() { parent::tearDownAfterClass(); $fs = new Filesystem(); foreach (self::$cleanup as $folder) { $fs->remove($folder); } }
/** * Create a new sub project * @param string $projectName * @param boolean $rebuild * @return string */ public static function createNewProject($projectName, $rebuild = false, $deleteServices = true) { $fs = new Filesystem(); $projectFolder = TEMP_DIR . '/TestProjects/' . $projectName; if ($rebuild) { if ($fs->exists($projectFolder)) { $fs->remove($projectFolder); } } $fs->ensureFolder($projectFolder); $projectFolder = realpath($projectFolder); self::runCommand($projectFolder, 'init'); if ($deleteServices) { file_put_contents($projectFolder . '/config/services.json', json_encode([])); } return $projectFolder; }
/** * Creates a Logger component */ private function createLogger() { $logFolder = $this->filesystem->assertFolderWritable($this->rootFolder . '/var/log'); $logLevel = $this->debug === true ? LogLevel::DEBUG : $this->config->get('logger.level', LogLevel::WARNING); $args = [$logFolder, $this->config->get('logger.name', 'application'), $this->config->get('logger.filelogger.maxfiles', 10), $logLevel]; $this->logger = (new \ReflectionClass($this->loggerFactory))->newInstanceArgs($args)->create(); $this->logger->debug('Logger started'); }
/** * Try to cache the callback result on disk * @param type $cacheFile * @param \Blend\Component\Cache\callable $callback * @return mixed */ private function withFile($cacheFile, callable $callback) { if ($this->filesystem->exists($cacheFile)) { return unserialize(file_get_contents($cacheFile)); } else { $result = call_user_func($callback); file_put_contents($cacheFile, serialize($result)); return $result; } }
protected function initializeSession(Request $request) { if (!$request->hasSession()) { if (!$this->container->isDefined(SessionProviderInterface::class)) { $savePath = $this->filesystem->assertFolderWritable($this->rootFolder . '/var/session'); $this->container->defineSingletonWithInterface(SessionProviderInterface::class, NativeSessionProvider::class, ['save_path' => $savePath]); } /* @var $provider SessionProviderInterface */ $provider = $this->container->get(SessionProviderInterface::class); $provider->initializeSession($request); $this->container->setScalar(SessionInterface::class, $provider->getSession()); } }
public function __construct($projectFolder) { $this->projectFolder = $projectFolder; $this->targetRootFolder = $projectFolder . '/src'; $this->modelFactoryMethods = []; $fs = new Filesystem(); $fs->ensureFolder($this->targetRootFolder); $this->registerModelFactoryMethods(); }
protected function setUp() { if (is_windows()) { $fs = new Filesystem(); $fs->remove(self::$projectFolder . '/src/Database'); } }
protected function tearDown() { parent::tearDown(); $fs = new Filesystem(); $fs->remove($this->cleanup); }
/** * Render of copy the file to the correct location * @param Filesystem $fs * @param string $relativeName * @param SplFileInfo $source * @param string $dest * @param OutputInterface $output */ private function processFile($fs, $relativeName, $source, $dest, OutputInterface $output) { if (in_array($relativeName, $this->renderTable)) { $output->writeln("Rendering " . $relativeName); render_php_template($source, $this->renderContext, $dest); if ($relativeName === 'bin/app') { chmod($dest, 0750); } } else { $output->writeln("Processing " . $relativeName); $fs->copy($source, $dest); } }