本文整理匯總了PHP中Assetic\Asset\AssetInterface::setTargetPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP AssetInterface::setTargetPath方法的具體用法?PHP AssetInterface::setTargetPath怎麽用?PHP AssetInterface::setTargetPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assetic\Asset\AssetInterface
的用法示例。
在下文中一共展示了AssetInterface::setTargetPath方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
public function process(AssetInterface $asset)
{
$hash = hash_init('sha1');
switch ($this->strategy) {
case self::STRATEGY_MODIFICATION:
hash_update($hash, $asset->getLastModified());
break;
case self::STRATEGY_CONTENT:
hash_update($hash, $asset->dump());
break;
}
foreach ($asset as $i => $leaf) {
if ($sourcePath = $leaf->getSourcePath()) {
hash_update($hash, $sourcePath);
} else {
hash_update($hash, $i);
}
}
$hash = substr(hash_final($hash), 0, 7);
$url = $asset->getTargetPath();
$oldExt = pathinfo($url, PATHINFO_EXTENSION);
$newExt = '-' . $hash . '.' . $oldExt;
if (!$oldExt || 0 < preg_match('/' . preg_quote($newExt, '/') . '$/', $url)) {
return;
}
$asset->setTargetPath(substr($url, 0, (strlen($oldExt) + 1) * -1) . $newExt);
}
示例2: process
public function process(AssetInterface $asset, AssetFactory $factory)
{
$targetUrl = $asset->getTargetPath();
if ($targetUrl && '/' != $targetUrl[0] && 0 !== strpos($targetUrl, '_controller/')) {
$asset->setTargetPath('_controller/' . $targetUrl);
}
return $asset;
}
示例3: process
public function process(AssetInterface $asset, AssetFactory $factory)
{
$path = $asset->getTargetPath();
$ext = pathinfo($path, PATHINFO_EXTENSION);
$lastModified = $asset->getLastModified();
if (null !== $lastModified) {
$path = substr_replace($path, "{$lastModified}.{$ext}", -1 * strlen($ext));
$asset->setTargetPath($path);
}
}
示例4: process
/**
* Processes an asset.
*
* @param AssetInterface $asset An asset
*
* @return AssetInterface|null May optionally return a replacement asset
*/
public function process(AssetInterface $asset)
{
$path = $asset->getTargetPath();
$ext = pathinfo($path, PATHINFO_EXTENSION);
$revision = $this->getRevision();
if (null !== $revision) {
$path = substr_replace($path, "{$revision}.{$ext}", -1 * strlen($ext));
$asset->setTargetPath($path);
}
}
示例5: filterDump
public function filterDump(AssetInterface $asset)
{
$originalTargetPath = $asset->getTargetPath();
$targetPath = str_replace('_controller/', '', $originalTargetPath);
$asset->setTargetPath($targetPath);
try {
parent::filterDump($asset);
} catch (\Exception $e) {
if ($targetPath === $asset->getTargetPath()) {
$asset->setTargetPath($originalTargetPath);
}
throw $e;
}
if ($targetPath === $asset->getTargetPath()) {
$asset->setTargetPath($originalTargetPath);
}
}
示例6: createInnerAsset
private function createInnerAsset()
{
if ($this->innerAsset) {
throw new RuntimeException('The inner asset must be created only once.');
}
$this->innerAsset = $this->factory->parseInputWithFixedValues($this->input, $this->currentDir, $this->roots, $this->vars, $this->values);
foreach ($this->filters as $filter) {
$this->innerAsset->ensureFilter($filter);
}
if (null !== $this->content) {
$this->innerAsset->setContent($this->content);
}
if (null !== $this->targetPath) {
$this->innerAsset->setTargetPath($this->targetPath);
}
// GC
$this->factory = null;
$this->input = null;
$this->currentDir = null;
$this->roots = null;
$this->content = null;
$this->targetPath = null;
}
示例7: setTargetPath
/**
* Sets the URL for the current asset.
*
* @param string $targetPath A web URL where the asset will be dumped
*/
public function setTargetPath($targetPath)
{
$this->asset->setTargetPath($targetPath);
}