本文整理汇总了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);
}