-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sasezaki/view-marshal-response
Introduce ViewModel
- Loading branch information
Showing
5 changed files
with
69 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
<?php | ||
|
||
namespace Backbeard; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface ViewInterface | ||
{ | ||
/** | ||
* @param array $array | ||
* @param ViewModelInterface $model | ||
* @param ResponseInterface $response | ||
* @return ResponseInterface | ||
*/ | ||
public function assign($array); | ||
|
||
/** | ||
* @param string $template | ||
* @param resoure|\Psr\Http\Message\StreamInterface $stream | ||
* | ||
* @return \Psr\Http\Message\StreamInterface | ||
*/ | ||
public function render($template, $stream = null); | ||
public function marshalResponse(ViewModelInterface $model, ResponseInterface $response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Backbeard; | ||
|
||
class ViewModel implements ViewModelInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $variables; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $template; | ||
|
||
/** | ||
* @param array $variables | ||
* @param string $template | ||
*/ | ||
public function __construct($variables, $template) | ||
{ | ||
$this->variables = $variables; | ||
$this->template = $template; | ||
} | ||
|
||
public function getVariables() | ||
{ | ||
return $this->variables; | ||
} | ||
|
||
public function getTemplate() | ||
{ | ||
return $this->template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Backbeard; | ||
|
||
interface ViewModelInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getVariables(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTemplate(); | ||
} |