Example #1
0
/**
 * Static resource path builder.
 *
 * @deprecated Moving to use new samsonphp/view resource an $this->src() should be used
 *             in view file for generating paths to static resources
 *
 * @param string $path   Relative static resource resource path
 * @param null   $module Entity for path building, if not passed current resource is used
 *
 * @return string Static resource path
 * @throws \samsonphp\resource\exception\ResourceNotFound
 */
function src($path, $module = null)
{
    // Define resource
    switch (gettype($module)) {
        case 'string':
            // Find resource by identifier
            $module = m($module);
            break;
        case 'object':
            // Do nothing
            break;
        default:
            // Get current resource
            $module = m();
    }
    echo '/' . STATIC_RESOURCE_HANDLER . '/?p=' . ResourceValidator::getRelativePath($path, $module->path(), dirname(getcwd()));
}