/
FileLocatorView.php
54 lines (44 loc) · 1.14 KB
/
FileLocatorView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Concrete\Core\View;
use Concrete\Core\Filesystem\FileLocator;
use Concrete\Core\Filesystem\FileLocatorInterface;
use Concrete\Core\Filesystem\LocatableFileInterface;
class FileLocatorView extends AbstractView
{
/**
* @var $locator LocatableFileInterface
*/
protected $locator;
public function constructView($locator)
{
$this->locator = $locator;
}
public function start($state)
{
if ($this->controller) {
$this->controller->runTask('view', array());
}
}
protected function onBeforeGetContents()
{
}
public function action($action)
{
$a = func_get_args();
$c = \Page::getCurrentPage();
array_unshift($a, $c);
return call_user_func_array(array('\URL', 'to'), $a);
}
public function setupRender()
{
$r = $this->locator->getFileLocatorRecord();
if (!$r->exists()) {
throw new \RuntimeException(t('File %s does not exist', $r->file));
}
$this->setViewTemplate($r->getFile());
}
public function finishRender($contents)
{
echo $contents;
}
}