PHP Класс Prado\Web\TAssetManager

TAssetManager provides a scheme to allow web clients visiting private files that are normally web-inaccessible. TAssetManager will copy the file to be published into a web-accessible directory. The default base directory for storing the file is "assets", which should be under the application directory. This can be changed by setting the {@link setBasePath BasePath} property together with the {@link setBaseUrl BaseUrl} property that refers to the URL for accessing the base path. By default, TAssetManager will not publish a file or directory if it already exists in the publishing directory and has an older modification time. If the application mode is set as 'Performance', the modification time check will be skipped. You can explicitly require a modification time check with the function {@link publishFilePath}. This is usually very useful during development. TAssetManager may be configured in application configuration file as follows, where {@link getBasePath BasePath} and {@link getBaseUrl BaseUrl} are configurable properties of TAssetManager. Make sure that BasePath is a namespace pointing to a valid directory writable by the Web server process.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TModule
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
copyDirectory ( $src, $dst ) Copies a directory recursively as another.
getBasePath ( ) : string
getBaseUrl ( ) : string
getPublished ( ) : array
getPublishedPath ( $path ) : string Returns the published path of a file path.
getPublishedUrl ( $path ) : string Returns the URL of a published file path.
init ( $config ) Initializes the module.
publishFilePath ( $path, $checkTimestamp = false ) : string Publishes a file or a directory (recursively).
publishTarFile ( $tarfile, $md5sum, $checkTimestamp = false ) : string Publish a tar file by extracting its contents to the assets directory.
setBasePath ( $value ) Sets the root directory storing published asset files.
setBaseUrl ( $value )

Защищенные методы

Метод Описание
copyFile ( $src, $dst ) Copies a file to a directory.
deployTarFile ( $path, $destination ) : boolean Extracts the tar file to the destination directory.
hash ( $dir ) : string Generate a CRC32 hash for the directory path. Collisions are higher than MD5 but generates a much smaller hash string.
setPublished ( $values = [] )

Описание методов

copyDirectory() публичный метод

If the destination directory does not exist, it will be created. File modification time is used to ensure the copied files are latest.
public copyDirectory ( $src, $dst )

copyFile() защищенный метод

Copying is done only when the destination file does not exist or has an older file modification time.
protected copyFile ( $src, $dst )

deployTarFile() защищенный метод

N.B Tar file must not be compressed.
protected deployTarFile ( $path, $destination ) : boolean
Результат boolean true if extract successful, false otherwise.

getBasePath() публичный метод

public getBasePath ( ) : string
Результат string the root directory storing published asset files

getBaseUrl() публичный метод

public getBaseUrl ( ) : string
Результат string the base url that the published asset files can be accessed

getPublished() публичный метод

С версии: 3.1.6
public getPublished ( ) : array
Результат array List of published assets

getPublishedPath() публичный метод

This method does not perform any publishing. It merely tells you if the file path is published, where it will go.
public getPublishedPath ( $path ) : string
Результат string the published file path

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

hash() защищенный метод

Generate a CRC32 hash for the directory path. Collisions are higher than MD5 but generates a much smaller hash string.
protected hash ( $dir ) : string
Результат string hashed string.

init() публичный метод

This method is required by IModule and is invoked by application.
public init ( $config )

publishFilePath() публичный метод

This method will copy the content in a directory (recursively) to a web accessible directory and returns the URL for the directory. If the application is not in performance mode, the file modification time will be used to make sure the published file is latest or not. If not, a file copy will be performed.
public publishFilePath ( $path, $checkTimestamp = false ) : string
Результат string an absolute URL to the published directory

publishTarFile() публичный метод

Each tar file must be accomplished with its own MD5 check sum file. The MD5 file is published when the tar contents are successfully extracted to the assets directory. The presence of the MD5 file as published asset assumes that the tar file has already been extracted.
public publishTarFile ( $tarfile, $md5sum, $checkTimestamp = false ) : string
Результат string URL path to the directory where the tar file was extracted.

setBasePath() публичный метод

The directory must be in namespace format.
public setBasePath ( $value )

setBaseUrl() публичный метод

public setBaseUrl ( $value )

setPublished() защищенный метод

С версии: 3.1.6
protected setPublished ( $values = [] )
$values List of published assets