예제 #1
0
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     $fs = new Filesystem();
     foreach (self::$cleanup as $folder) {
         $fs->remove($folder);
     }
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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');
 }
예제 #4
0
 /**
  * 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;
     }
 }
예제 #5
0
 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());
     }
 }
예제 #6
0
 public function __construct($projectFolder)
 {
     $this->projectFolder = $projectFolder;
     $this->targetRootFolder = $projectFolder . '/src';
     $this->modelFactoryMethods = [];
     $fs = new Filesystem();
     $fs->ensureFolder($this->targetRootFolder);
     $this->registerModelFactoryMethods();
 }
예제 #7
0
 protected function setUp()
 {
     if (is_windows()) {
         $fs = new Filesystem();
         $fs->remove(self::$projectFolder . '/src/Database');
     }
 }
예제 #8
0
 protected function tearDown()
 {
     parent::tearDown();
     $fs = new Filesystem();
     $fs->remove($this->cleanup);
 }
예제 #9
0
 /**
  * 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);
     }
 }