Prado\Web\TAssetManager::init PHP Method

init() public method

This method is required by IModule and is invoked by application.
public init ( $config )
    public function init($config)
    {
        $application = $this->getApplication();
        if ($this->_basePath === null) {
            $this->_basePath = dirname($application->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
        }
        if (!is_writable($this->_basePath) || !is_dir($this->_basePath)) {
            throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath);
        }
        if ($this->_baseUrl === null) {
            $this->_baseUrl = rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\') . '/' . self::DEFAULT_BASEPATH;
        }
        $application->setAssetManager($this);
        $this->_initialized = true;
    }

Usage Example

Esempio n. 1
0
 public function testPublishTarFile()
 {
     $manager = new TAssetManager();
     $manager->setBaseUrl('/');
     $manager->init(null);
     $tarFile = dirname(__FILE__) . '/data/aTarFile.tar';
     $md5File = dirname(__FILE__) . '/data/aTarFile.md5';
     // First, try with bad md5
     try {
         $manager->publishTarFile($tarFile, 'badMd5File');
         self::fail('Expected TInvalidDataValueException not thrown');
     } catch (TInvalidDataValueException $e) {
     }
     // Then, try with real md5 file
     $publishedUrl = $manager->publishTarFile($tarFile, $md5File);
     $publishedDir = self::$assetDir . $publishedUrl;
     self::assertTrue(is_dir($publishedDir));
     self::assertTrue(is_file($publishedDir . '/pradoheader.gif'));
     self::assertTrue(is_file($publishedDir . '/aTarFile.md5'));
 }