writer() public method

Create an AssetWriter
public writer ( string $tmpPath = '' ) : MiniAsset\AssetWriter
$tmpPath string The path where the build timestamp lookup should be stored.
return MiniAsset\AssetWriter
Beispiel #1
0
 /**
  * Generate and save the cached file for a build target.
  *
  * @param \MiniAsset\Factory $factory The factory class.
  * @param \MiniAsset\AssetTarget $build The build target.
  * @return void
  */
 protected function _buildTarget($factory, $build)
 {
     $writer = $factory->writer();
     $compiler = $factory->cachedCompiler();
     $name = $writer->buildFileName($build);
     if ($writer->isFresh($build) && !$this->cli->arguments->defined('force')) {
         $this->verbose('<light_blue>Skip building</light_blue> ' . $name . ' existing file is still fresh.', 'S');
         return;
     }
     $writer->invalidate($build);
     $name = $writer->buildFileName($build);
     try {
         $contents = $compiler->generate($build);
         $writer->write($build, $contents);
         $this->verbose('<green>Saved file</green> for ' . $name, '.');
     } catch (Exception $e) {
         $this->cli->err('<red>Error:</red> ' . $e->getMessage());
     }
 }
 protected function execute()
 {
     if ($this->cli->arguments->defined('bootstrap')) {
         $this->bootstrapApp();
     }
     $config = $this->config();
     $factory = new Factory($config);
     $this->verbose('Clearing build timestamps.');
     $writer = $factory->writer();
     $writer->clearTimestamps();
     $this->verbose('Clearing build files:');
     $assets = $factory->assetCollection();
     if (count($assets) === 0) {
         $this->cli->err('<red>No build targets defined</red>.');
         return 1;
     }
     $targets = array_map(function ($target) {
         return $target->name();
     }, iterator_to_array($assets));
     $this->_clearPath($config->cachePath('js'), $targets);
     $this->_clearPath($config->cachePath('css'), $targets);
     $this->cli->out('<green>Complete</green>');
 }
 public function testWriter()
 {
     $config = AssetConfig::buildFromIniFile($this->integrationFile);
     $config->theme('Red');
     $config->set('js.timestamp', true);
     $factory = new Factory($config);
     $writer = $factory->writer();
     $expected = ['timestamp' => ['js' => true, 'css' => false], 'path' => TMP, 'theme' => 'Red'];
     $this->assertEquals($expected, $writer->config());
 }
Beispiel #4
0
 /**
  * Create an AssetWriter
  *
  * @param string $path The path to use
  * @return \MiniAsset\Output\AssetWriter
  */
 public function writer($path = TMP)
 {
     return parent::writer($path);
 }