Vendor lock
This commit is contained in:
102
vendor/illuminate/view/Engines/CompilerEngine.php
vendored
Executable file
102
vendor/illuminate/view/Engines/CompilerEngine.php
vendored
Executable file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\View\Engines;
|
||||
|
||||
use Exception;
|
||||
use ErrorException;
|
||||
use Illuminate\View\Compilers\CompilerInterface;
|
||||
|
||||
class CompilerEngine extends PhpEngine
|
||||
{
|
||||
/**
|
||||
* The Blade compiler instance.
|
||||
*
|
||||
* @var \Illuminate\View\Compilers\CompilerInterface
|
||||
*/
|
||||
protected $compiler;
|
||||
|
||||
/**
|
||||
* A stack of the last compiled templates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $lastCompiled = [];
|
||||
|
||||
/**
|
||||
* Create a new Blade view engine instance.
|
||||
*
|
||||
* @param \Illuminate\View\Compilers\CompilerInterface $compiler
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CompilerInterface $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the evaluated contents of the view.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function get($path, array $data = [])
|
||||
{
|
||||
$this->lastCompiled[] = $path;
|
||||
|
||||
// If this given view has expired, which means it has simply been edited since
|
||||
// it was last compiled, we will re-compile the views so we can evaluate a
|
||||
// fresh copy of the view. We'll pass the compiler the path of the view.
|
||||
if ($this->compiler->isExpired($path)) {
|
||||
$this->compiler->compile($path);
|
||||
}
|
||||
|
||||
$compiled = $this->compiler->getCompiledPath($path);
|
||||
|
||||
// Once we have the path to the compiled file, we will evaluate the paths with
|
||||
// typical PHP just like any other templates. We also keep a stack of views
|
||||
// which have been rendered for right exception messages to be generated.
|
||||
$results = $this->evaluatePath($compiled, $data);
|
||||
|
||||
array_pop($this->lastCompiled);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a view exception.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param int $obLevel
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function handleViewException(Exception $e, $obLevel)
|
||||
{
|
||||
$e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e);
|
||||
|
||||
parent::handleViewException($e, $obLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the exception message for an exception.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return string
|
||||
*/
|
||||
protected function getMessage(Exception $e)
|
||||
{
|
||||
return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compiler implementation.
|
||||
*
|
||||
* @return \Illuminate\View\Compilers\CompilerInterface
|
||||
*/
|
||||
public function getCompiler()
|
||||
{
|
||||
return $this->compiler;
|
||||
}
|
||||
}
|
23
vendor/illuminate/view/Engines/Engine.php
vendored
Executable file
23
vendor/illuminate/view/Engines/Engine.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\View\Engines;
|
||||
|
||||
abstract class Engine
|
||||
{
|
||||
/**
|
||||
* The view that was last to be rendered.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lastRendered;
|
||||
|
||||
/**
|
||||
* Get the last view that was rendered.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastRendered()
|
||||
{
|
||||
return $this->lastRendered;
|
||||
}
|
||||
}
|
60
vendor/illuminate/view/Engines/EngineResolver.php
vendored
Executable file
60
vendor/illuminate/view/Engines/EngineResolver.php
vendored
Executable file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\View\Engines;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class EngineResolver
|
||||
{
|
||||
/**
|
||||
* The array of engine resolvers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $resolvers = [];
|
||||
|
||||
/**
|
||||
* The resolved engine instances.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $resolved = [];
|
||||
|
||||
/**
|
||||
* Register a new engine resolver.
|
||||
*
|
||||
* The engine string typically corresponds to a file extension.
|
||||
*
|
||||
* @param string $engine
|
||||
* @param \Closure $resolver
|
||||
* @return void
|
||||
*/
|
||||
public function register($engine, Closure $resolver)
|
||||
{
|
||||
unset($this->resolved[$engine]);
|
||||
|
||||
$this->resolvers[$engine] = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an engine instance by name.
|
||||
*
|
||||
* @param string $engine
|
||||
* @return \Illuminate\Contracts\View\Engine
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function resolve($engine)
|
||||
{
|
||||
if (isset($this->resolved[$engine])) {
|
||||
return $this->resolved[$engine];
|
||||
}
|
||||
|
||||
if (isset($this->resolvers[$engine])) {
|
||||
return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Engine [{$engine}] not found.");
|
||||
}
|
||||
}
|
20
vendor/illuminate/view/Engines/FileEngine.php
vendored
Normal file
20
vendor/illuminate/view/Engines/FileEngine.php
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\View\Engines;
|
||||
|
||||
use Illuminate\Contracts\View\Engine;
|
||||
|
||||
class FileEngine implements Engine
|
||||
{
|
||||
/**
|
||||
* Get the evaluated contents of the view.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function get($path, array $data = [])
|
||||
{
|
||||
return file_get_contents($path);
|
||||
}
|
||||
}
|
70
vendor/illuminate/view/Engines/PhpEngine.php
vendored
Executable file
70
vendor/illuminate/view/Engines/PhpEngine.php
vendored
Executable file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\View\Engines;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Contracts\View\Engine;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
|
||||
class PhpEngine implements Engine
|
||||
{
|
||||
/**
|
||||
* Get the evaluated contents of the view.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function get($path, array $data = [])
|
||||
{
|
||||
return $this->evaluatePath($path, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the evaluated contents of the view at the given path.
|
||||
*
|
||||
* @param string $__path
|
||||
* @param array $__data
|
||||
* @return string
|
||||
*/
|
||||
protected function evaluatePath($__path, $__data)
|
||||
{
|
||||
$obLevel = ob_get_level();
|
||||
|
||||
ob_start();
|
||||
|
||||
extract($__data, EXTR_SKIP);
|
||||
|
||||
// We'll evaluate the contents of the view inside a try/catch block so we can
|
||||
// flush out any stray output that might get out before an error occurs or
|
||||
// an exception is thrown. This prevents any partial views from leaking.
|
||||
try {
|
||||
include $__path;
|
||||
} catch (Exception $e) {
|
||||
$this->handleViewException($e, $obLevel);
|
||||
} catch (Throwable $e) {
|
||||
$this->handleViewException(new FatalThrowableError($e), $obLevel);
|
||||
}
|
||||
|
||||
return ltrim(ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a view exception.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param int $obLevel
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function handleViewException(Exception $e, $obLevel)
|
||||
{
|
||||
while (ob_get_level() > $obLevel) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user