canonicalizeViewName() public method

Takes a view name and returns the canonical name for that view.
public canonicalizeViewName ( string $alias ) : string
$alias string The possibly non-canonical view name.
return string The canonical view name.
Example #1
0
 /**
  * Get the URL for the cached view.
  *
  * Recommended usage is to just pass the entire view name as the first and only arg:
  *
  * ```
  * $blog_js = $simpleCache->getUrl('blog/save_draft.js');
  * $favicon = $simpleCache->getUrl('graphics/favicon.ico');
  * ```
  *
  * For backwards compatibility with older versions of Elgg, you can also pass
  * "js" or "css" as the first arg, with the rest of the view name as the second arg:
  *
  * ```
  * $blog_js = $simpleCache->getUrl('js', 'blog/save_draft.js');
  * ```
  *
  * This automatically registers the view with Elgg's simplecache.
  *
  * @param string $view    The full view name
  * @param string $subview If the first arg is "css" or "js", the rest of the view name
  *
  * @return string
  */
 function getUrl($view, $subview = '')
 {
     // handle `getUrl('js', 'js/blog/save_draft')`
     if (($view === 'js' || $view === 'css') && 0 === strpos($subview, $view . '/')) {
         $view = $subview;
         $subview = '';
     }
     // handle `getUrl('js', 'blog/save_draft')`
     if (!empty($subview)) {
         $view = "{$view}/{$subview}";
     }
     $view = $this->views->canonicalizeViewName($view);
     // should be normalized to canonical form by now: `getUrl('blog/save_draft.js')`
     $this->registerView($view);
     return $this->getRoot() . $view;
 }
Example #2
0
 /**
  * @dataProvider getExampleNormalizedViews
  */
 public function testDefaultNormalizeBehavior($canonical, $alias)
 {
     $this->assertEquals($canonical, $this->views->canonicalizeViewName($alias));
 }