/**
  * Publishes a file or a directory.
  *
  * Will use linkAssets even if $forceCopy is true
  *
  * @param string $path
  * @param bool $hashByName
  * @param int $level
  * @param null $forceCopy
  */
 public function publish($path, $hashByName = false, $level = -1, $forceCopy = null)
 {
     if ($forceCopy && $this->linkAssets) {
         $forceCopy = null;
     }
     return parent::publish($path, $hashByName, $level, $forceCopy);
 }
Esempio n. 2
0
 public function getBasePath()
 {
     if (php_sapi_name() === 'cli') {
         return Yii::getPathOfAlias('webroot.assets');
     }
     return parent::getBasePath();
 }
Esempio n. 3
0
 /**
  * Forces copy while debugging mode on
  * @param string $path
  * @param bool $hashByName
  * @param int $level
  * @param bool $forceCopy
  * @return string
  */
 public function publish($path, $hashByName = false, $level = -1, $forceCopy = false)
 {
     if (YII_DEBUG) {
         $forceCopy = true;
         $hashByName = false;
     }
     return parent::publish($path, $hashByName, $level, $forceCopy);
 }
 public function testPublishFile()
 {
     $app = new TestApplication();
     $app->reset();
     $am = new CAssetManager();
     $am->init($app);
     $path1 = $am->getPublishedPath(__FILE__);
     clearstatcache();
     $this->assertFalse(is_file($path1));
     $url = $am->publish(__FILE__);
     $path2 = $am->getPublishedPath(__FILE__);
     $this->assertEquals($path1, $path2);
     clearstatcache();
     $this->assertTrue(is_file($path1));
     $this->assertEquals(basename($path1), basename(__FILE__));
     $this->assertEquals($url, $am->baseUrl . '/' . basename(dirname($path2)) . '/' . basename($path2));
 }
 /**
  * @param string $path
  * @param bool $hashByName
  * @param int $level
  * @param null $forceCopy
  * @return mixed
  */
 public function publish($path, $hashByName = false, $level = -1, $forceCopy = null)
 {
     if (($src = realpath($path)) !== false) {
         switch (pathinfo($src, PATHINFO_EXTENSION)) {
             case 'less':
                 $path = $this->lessCompile($src);
         }
     }
     return parent::publish($path, $hashByName, $level, $forceCopy);
 }
Esempio n. 6
0
 /**
  * Initializes the component.
  */
 public function init()
 {
     $this->setClientScript(Yii::app()->clientScript);
     $this->setCacheBuster(Yii::app()->cacheBuster);
     parent::init();
 }
Esempio n. 7
0
 public function getBaseRelUrl()
 {
     return parent::getBaseUrl();
 }
Esempio n. 8
0
 public function getAssetManager()
 {
     $am = new CAssetManager();
     //$this->getComponent('widgetFactory');
     $am->setBasePath($this->getBasePath() . '/www/assets');
     return $am;
 }
Esempio n. 9
0
 public function init()
 {
     $this->setBaseUrl(Yii::app()->request->baseUrl . "/index.php/" . self::DEFAULT_BASEPATH);
     parent::init();
 }
Esempio n. 10
0
 public function publish($path, $hashByName = false, $level = -1, $forceCopy = null)
 {
     $hashByName = true;
     return parent::publish($path, $hashByName, $level, $forceCopy);
 }