added paths and extensions options to view class.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
parent
ca5dfa4061
commit
64b61abcd5
|
@ -37,6 +37,20 @@ class View implements ArrayAccess {
|
||||||
*/
|
*/
|
||||||
public static $names = array();
|
public static $names = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The extensions a view file can have.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $extensions = array(EXT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path in which a view can live.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $paths = array(DEFAULT_BUNDLE => array(''));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Laravel view engine event name.
|
* The Laravel view engine event name.
|
||||||
*
|
*
|
||||||
|
@ -99,11 +113,16 @@ protected function path($view)
|
||||||
// We need to make sure that the view exists. If it doesn't, we will
|
// We need to make sure that the view exists. If it doesn't, we will
|
||||||
// throw an exception since there is not any point in going further.
|
// throw an exception since there is not any point in going further.
|
||||||
// If it does, we can just return the full view path.
|
// If it does, we can just return the full view path.
|
||||||
$path = $root.Bundle::element($view).EXT;
|
$paths = array_get(static::$paths, Bundle::name($view), array(''));
|
||||||
|
|
||||||
if (file_exists($path))
|
foreach ($paths as $path)
|
||||||
{
|
{
|
||||||
return $path;
|
foreach (static::$extensions as $ext)
|
||||||
|
{
|
||||||
|
$file = $root.$path.Bundle::element($view).$ext;
|
||||||
|
|
||||||
|
if (file_exists($file)) return $file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception("View [$view] doesn't exist.");
|
throw new \Exception("View [$view] doesn't exist.");
|
||||||
|
@ -211,12 +230,12 @@ public function render()
|
||||||
// allows easy attachment of other view parsers.
|
// allows easy attachment of other view parsers.
|
||||||
if (Event::listeners(static::engine))
|
if (Event::listeners(static::engine))
|
||||||
{
|
{
|
||||||
return Event::first(static::engine, array($this));
|
$result = Event::first(static::engine, array($this));
|
||||||
}
|
|
||||||
else
|
if ($result !== false) return $result;
|
||||||
{
|
|
||||||
return $this->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue