Vendor lock
This commit is contained in:
3
vendor/rubellum/slim-blade-view/.gitignore
vendored
Normal file
3
vendor/rubellum/slim-blade-view/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
composer.lock
|
||||
vendor
|
||||
data/cache/*.php
|
21
vendor/rubellum/slim-blade-view/LICENSE
vendored
Normal file
21
vendor/rubellum/slim-blade-view/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Hiroaki Matsuura
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
1
vendor/rubellum/slim-blade-view/README.md
vendored
Normal file
1
vendor/rubellum/slim-blade-view/README.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Slim-Blade-View
|
34
vendor/rubellum/slim-blade-view/composer.json
vendored
Normal file
34
vendor/rubellum/slim-blade-view/composer.json
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "hiropeke/slim-blade-view",
|
||||
"type": "library",
|
||||
"description": "Slim Framework 3 view helper built on the Blade component",
|
||||
"keywords": [
|
||||
"slim",
|
||||
"framework",
|
||||
"view",
|
||||
"template",
|
||||
"blade",
|
||||
"renderer"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Hiroaki Matsuura",
|
||||
"email": "hiropeke.jp@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"illuminate/view": "5.*",
|
||||
"philo/laravel-blade": "3.*",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Slim\\Views\\": "src"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.0",
|
||||
"slim/slim": "^3.0"
|
||||
}
|
||||
}
|
1
vendor/rubellum/slim-blade-view/data/cache/.gitkeep
vendored
Normal file
1
vendor/rubellum/slim-blade-view/data/cache/.gitkeep
vendored
Normal file
@ -0,0 +1 @@
|
||||
#!/usr/bin/env bash
|
24
vendor/rubellum/slim-blade-view/phpunit.xml.dist
vendored
Normal file
24
vendor/rubellum/slim-blade-view/phpunit.xml.dist
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Renderer Tests">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
175
vendor/rubellum/slim-blade-view/src/Blade.php
vendored
Normal file
175
vendor/rubellum/slim-blade-view/src/Blade.php
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace Slim\Views;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class Blade
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $viewPaths;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cachePath;
|
||||
|
||||
/**
|
||||
* @var Dispatcher|null
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* Blade constructor.
|
||||
* @param array $viewPaths
|
||||
* @param $cachePath
|
||||
* @param Dispatcher|null $events
|
||||
*/
|
||||
public function __construct($viewPaths = [], $cachePath = '', Dispatcher $events = null, $attributes = [])
|
||||
{
|
||||
if (is_string($viewPaths)) {
|
||||
$viewPaths = [$viewPaths];
|
||||
}
|
||||
$this->viewPaths = $viewPaths;
|
||||
$this->cachePath = $cachePath;
|
||||
$this->events = $events;
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a template
|
||||
*
|
||||
* $data cannot contain template as a key
|
||||
*
|
||||
* throws RuntimeException if $templatePath . $template does not exist
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
* @param string $template
|
||||
* @param array $data
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function render(ResponseInterface $response, $template, array $data = [])
|
||||
{
|
||||
$output = $this->fetch($template, $data);
|
||||
$response->getBody()->write($output);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes for the renderer
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attributes for the renderer
|
||||
*
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function setAttributes(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attribute for the renderer
|
||||
*
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an attribute
|
||||
*
|
||||
* @param $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
if (!isset($this->attributes[$key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getViewPaths()
|
||||
{
|
||||
return $this->viewPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $viewPaths
|
||||
*/
|
||||
public function setViewPaths($viewPaths)
|
||||
{
|
||||
$this->viewPaths = $viewPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCachePath()
|
||||
{
|
||||
return $this->cachePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cachePath
|
||||
*/
|
||||
public function setCachePath($cachePath)
|
||||
{
|
||||
$this->cachePath = $cachePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a template and returns the result as a string
|
||||
*
|
||||
* cannot contain template as a key
|
||||
*
|
||||
* throws RuntimeException if $templatePath . $template does not exist
|
||||
*
|
||||
* @param $template
|
||||
* @param array $data
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function fetch($template, array $data = [])
|
||||
{
|
||||
if (isset($data['template'])) {
|
||||
throw new \InvalidArgumentException("Duplicate template key found");
|
||||
}
|
||||
|
||||
$data = array_merge($this->attributes, $data);
|
||||
|
||||
$renderer = new \Philo\Blade\Blade($this->viewPaths, $this->cachePath, $this->events);
|
||||
return $renderer->view()->make($template, $data)->render();
|
||||
}
|
||||
}
|
77
vendor/rubellum/slim-blade-view/tests/BladeTest.php
vendored
Normal file
77
vendor/rubellum/slim-blade-view/tests/BladeTest.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Slim\Tests\Views;
|
||||
|
||||
use Slim\Views\Blade;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
class BladeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Blade
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->view = new Blade([__DIR__ . '/templates', __DIR__ . '/another'], __DIR__ . '/../data/cache');
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
{
|
||||
$output = $this->view->fetch('example', [
|
||||
'name' => 'Josh',
|
||||
]);
|
||||
$this->assertEquals("<p>Hi, my name is Josh.</p>\n", $output);
|
||||
}
|
||||
|
||||
public function testSingleTemplateWithANamespace()
|
||||
{
|
||||
$views = new Blade([
|
||||
'One' => __DIR__ . '/templates',
|
||||
]);
|
||||
$output = $views->fetch('example', [
|
||||
'name' => 'Josh',
|
||||
]);
|
||||
$this->assertEquals("<p>Hi, my name is Josh.</p>\n", $output);
|
||||
}
|
||||
|
||||
public function testMultipleTemplatesWithMulNamespace()
|
||||
{
|
||||
$views = new Blade([
|
||||
'One' => __DIR__ . '/templates',
|
||||
'Two' => __DIR__ . '/another',
|
||||
]);
|
||||
$outputOne = $views->fetch('example', [
|
||||
'name' => 'Peter',
|
||||
]);
|
||||
$outputTwo = $views->fetch('example2', [
|
||||
'name' => 'Peter',
|
||||
'gender' => 'male',
|
||||
]);
|
||||
$this->assertEquals("<p>Hi, my name is Peter.</p>\n", $outputOne);
|
||||
$this->assertEquals("<p>Hi, my name is Peter and I am male.</p>\n", $outputTwo);
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$mockBody = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mockResponse = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mockBody->expects($this->once())
|
||||
->method('write')
|
||||
->with("<p>Hi, my name is Josh.</p>\n")
|
||||
->willReturn(28);
|
||||
$mockResponse->expects($this->once())
|
||||
->method('getBody')
|
||||
->willReturn($mockBody);
|
||||
$response = $this->view->render($mockResponse, 'example', [
|
||||
'name' => 'Josh',
|
||||
]);
|
||||
$this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response);
|
||||
}
|
||||
}
|
1
vendor/rubellum/slim-blade-view/tests/another/example2.blade.php
vendored
Normal file
1
vendor/rubellum/slim-blade-view/tests/another/example2.blade.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<p>Hi, my name is {{ $name }} and I am {{ $gender }}.</p>
|
1
vendor/rubellum/slim-blade-view/tests/templates/example.blade.php
vendored
Normal file
1
vendor/rubellum/slim-blade-view/tests/templates/example.blade.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<p>Hi, my name is {{ $name }}.</p>
|
Reference in New Issue
Block a user