Prado\Web\TAssetManager::setBasePath PHP 메소드

setBasePath() 공개 메소드

The directory must be in namespace format.
public setBasePath ( $value )
    public function setBasePath($value)
    {
        if ($this->_initialized) {
            throw new TInvalidOperationException('assetmanager_basepath_unchangeable');
        } else {
            $this->_basePath = Prado::getPathOfNamespace($value);
            if ($this->_basePath === null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) {
                throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value);
            }
        }
    }

Usage Example

예제 #1
0
 public function testSetBasePath()
 {
     $manager = new TAssetManager();
     // First try, invalid directory
     try {
         $manager->setBasePath('invalid');
         self::fail('Expected TInvalidDataValueException not thrown');
     } catch (TInvalidDataValueException $e) {
     }
     // Next, standard asset directory, should work
     $manager->setBasePath('AssetAlias');
     self::assertEquals(self::$assetDir, $manager->getBasePath());
     // Finally, test to change after init
     $manager->init(null);
     try {
         $manager->setBasePath('test');
         self::fail('Expected TInvalidOperationException not thrown');
     } catch (TInvalidOperationException $e) {
     }
 }