This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/Rails/ActionView/Helper/Methods/Assets.php

31 lines
920 B
PHP
Raw Normal View History

2013-10-02 08:12:58 +02:00
<?php
namespace Rails\ActionView\Helper\Methods;
trait Assets
{
public function assetPath($source, array $options = [])
{
if (strpos($source, '/') !== 0 && strpos($source, 'http') !== 0) {
if (!isset($options['digest'])) {
$options['digest'] = true;
}
if (\Rails::config()->assets->enabled) {
if (\Rails::config()->serve_static_assets && $options['digest']) {
if ($url = \Rails::assets()->findCompiledFile($source)) {
return $url;
}
}
if ($file = \Rails::assets()->findFile($source)) {
return $file->url();
}
}
return \Rails::application()->router()->rootPath() . $source;
} else {
return $source;
}
}
}