Prado\Web\TAssetManager::getPublishedUrl PHP Method

getPublishedUrl() public method

This method does not perform any publishing. It merely tells you if the file path is published, what the URL will be to access it.
public getPublishedUrl ( $path ) : string
return string the published URL for the file path
    public function getPublishedUrl($path)
    {
        $path = realpath($path);
        if (is_file($path)) {
            return $this->_baseUrl . '/' . $this->hash(dirname($path)) . '/' . basename($path);
        } else {
            return $this->_baseUrl . '/' . $this->hash($path);
        }
    }

Usage Example

コード例 #1
0
ファイル: TAssetManagerTest.php プロジェクト: pradosoft/prado
 public function testPublishFilePathWithDirectory()
 {
     $manager = new TAssetManager();
     $manager->setBaseUrl('/');
     $manager->init(null);
     // Try to publish a directory
     $dirToPublish = dirname(__FILE__) . '/data';
     $publishedUrl = $manager->publishFilePath($dirToPublish);
     $publishedDir = self::$assetDir . $publishedUrl;
     self::assertEquals($publishedDir, $manager->getPublishedPath($dirToPublish));
     self::assertEquals($publishedUrl, $manager->getPublishedUrl($dirToPublish));
     self::assertTrue(is_dir($publishedDir));
     self::assertTrue(is_file($publishedDir . '/pradoheader.gif'));
 }