|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Schnoop\RemoteTemplate\View; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
6
|
|
|
use Schnoop\RemoteTemplate\Exceptions\IgnoredUrlSuffixException; |
|
7
|
|
|
use Schnoop\RemoteTemplate\Exceptions\RemoteHostNotConfiguredException; |
|
8
|
|
|
use Schnoop\RemoteTemplate\Exceptions\RemoteTemplateNotFoundException; |
|
9
|
|
|
use Schnoop\RemoteTemplate\Exceptions\UrlIsForbiddenException; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class FileViewFinder. |
|
13
|
|
|
*/ |
|
14
|
|
|
class FileViewFinder extends \Illuminate\View\FileViewFinder |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var RemoteTemplateFinder |
|
18
|
|
|
*/ |
|
19
|
|
|
private $remoteView; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Create a new file view loader instance. |
|
23
|
|
|
* |
|
24
|
|
|
* @param Filesystem $files |
|
25
|
|
|
* @param array $paths |
|
26
|
|
|
* @param RemoteTemplateFinder $remoteView |
|
27
|
|
|
* @param array $extensions |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct( |
|
30
|
|
|
Filesystem $files, |
|
31
|
|
|
array $paths, |
|
32
|
|
|
RemoteTemplateFinder $remoteView, |
|
33
|
|
|
array $extensions = null |
|
34
|
|
|
) { |
|
35
|
|
|
parent::__construct($files, $paths, $extensions); |
|
36
|
|
|
$this->remoteView = $remoteView; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get the fully qualified location of the view. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $name |
|
43
|
|
|
* |
|
44
|
|
|
* @return string |
|
45
|
|
|
* @throws IgnoredUrlSuffixException |
|
46
|
|
|
* @throws RemoteTemplateNotFoundException |
|
47
|
|
|
* @throws RemoteHostNotConfiguredException |
|
48
|
|
|
* @throws UrlIsForbiddenException |
|
49
|
|
|
*/ |
|
50
|
|
|
public function find($name): string |
|
51
|
|
|
{ |
|
52
|
|
|
if (isset($this->views[$name])) { |
|
53
|
|
|
return $this->views[$name]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
if ($this->remoteView->hasRemoteInformation($name = trim($name)) === true) { |
|
57
|
|
|
return $this->views[$name] = $this->remoteView->findRemotePathView($name); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return parent::find($name); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|