示例#1
0
 protected function executeGenerateBootstrap(array $config)
 {
     // In the template for bootstrap.less we need the path where Bootstraps .less files are stored and the path
     // to the variables.less file.
     // Absolute path do not work in LESSs import statement, we have to calculate the relative ones
     $lessDir = $this->pathUtil->getRelativePath(dirname($config['bootstrap_output']), $this->getContainer()->getParameter('braincrafted_bootstrap.assets_dir'));
     $variablesDir = $this->pathUtil->getRelativePath(dirname($config['bootstrap_output']), dirname($config['variables_file']));
     $variablesFile = sprintf('%s%s%s', $variablesDir, strlen($variablesDir) > 0 ? '/' : '', basename($config['variables_file']));
     // We can now use Twig to render the bootstrap.less file and save it
     $content = $this->getContainer()->get('twig')->render($config['bootstrap_template'], array('variables_file' => $variablesFile, 'assets_dir' => $lessDir));
     file_put_contents($config['bootstrap_output'], $content);
 }
 /**
  * @param $expected string
  * @param $from     string
  * @param $to       string
  *
  * @covers Braincrafted\Bundle\BootstrapBundle\Util\PathUtil::getRelativePath()
  * @dataProvider relativePathProvider
  */
 public function testGetRelativePath($expected, $from, $to)
 {
     $this->assertEquals($expected, $this->util->getRelativePath($from, $to));
 }