Prado\Web\TAssetManager::getPublishedUrl PHP Метод

getPublishedUrl() публичный Метод

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
Результат 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
 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'));
 }