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/Routing/Traits/NamedPathAwareTrait.php
2013-10-02 01:12:58 -05:00

24 lines
672 B
PHP
Executable File

<?php
namespace Rails\Routing\Traits;
/**
* These methods are expected to be used in __call() magic methods,
* to dynamically search for named paths (for routes with alias).
*/
trait NamedPathAwareTrait
{
protected function isNamedPathMethod($method)
{
return strpos($method, 'Path') === strlen($method) - 4;
}
protected function getNamedPath($method, array $params = [])
{
$alias = \Rails::services()->get('inflector')->underscore(substr($method, 0, -4));
return \Rails::application()
->router()
->url_helpers()
->find_route_with_alias($alias, $params);
}
}