本文整理匯總了PHP中Assetic\Asset\StringAsset::getTargetPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringAsset::getTargetPath方法的具體用法?PHP StringAsset::getTargetPath怎麽用?PHP StringAsset::getTargetPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assetic\Asset\StringAsset
的用法示例。
在下文中一共展示了StringAsset::getTargetPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filterResource
/**
* Filter resource.
*
* Filter resource, applying filters and saving output into output location.
*
* @param ResourceInterface $resource Resource to filter.
* @return ResourceInterface Resulting filtered resources.
*/
private function filterResource(ResourceInterface $resource, array $filters)
{
if ($resource instanceof FileResource) {
$asset = new FileAsset($resource->getSource(), $filters);
} elseif ($resource instanceof HttpResource) {
$asset = new HttpAsset($resource->getSource(), $filters);
} elseif ($resource instanceof StringResource) {
$asset = new StringAsset($resource->getSource(), $filters, $resource->getSourceRoot());
} else {
throw new InvalidArgumentException(sprintf('Instance of "%s" expected, "%s" given.', implode('", "', array('RunOpenCode\\AssetsInjection\\Resource\\FileResource', 'RunOpenCode\\AssetsInjection\\Resource\\HttpResource', 'RunOpenCode\\AssetsInjection\\Resource\\StringResource')), get_class($resource)));
}
$asset->setTargetPath($this->calculateTargetFilename($resource));
$path = sprintf('%s%s%s', $this->options['output_dir'], DIRECTORY_SEPARATOR, $asset->getTargetPath());
if (!file_exists($path) || filectime($path) !== $resource->getLastModified()) {
$this->assetWriter->writeAsset($asset);
touch($path, $resource->getLastModified() ? $resource->getLastModified() : time());
}
return new FileResource($path);
}