-
Notifications
You must be signed in to change notification settings - Fork 210
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 #772 from LuckyCyborg/master
Introducing Core\Template, a View specialized to handle Template files
- Loading branch information
Showing
3 changed files
with
110 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Template - a View specialized for handling the Template files. | ||
* | ||
* @author Virgil-Adrian Teaca - [email protected] | ||
* @version 3.0 | ||
*/ | ||
|
||
namespace Core; | ||
|
||
use Core\View; | ||
|
||
|
||
class Template extends View | ||
{ | ||
/** | ||
* Constructor | ||
* @param mixed $path | ||
* @param array $data | ||
* | ||
* @throws \UnexpectedValueException | ||
*/ | ||
public function __construct($path, array $data = array()) | ||
{ | ||
parent::__construct($path, $data); | ||
} | ||
|
||
/** | ||
* Create a Template instance | ||
* | ||
* @param string $path | ||
* @param array $data | ||
* @param string $custom | ||
* @return Template | ||
*/ | ||
public static function make($path, array $data = array(), $custom = TEMPLATE) | ||
{ | ||
// Prepare the file path. | ||
$filePath = str_replace('/', DS, "Templates/$custom/$path.php"); | ||
|
||
return new Template(APPDIR .$filePath, $data); | ||
} | ||
|
||
/** | ||
* Magic Method for handling dynamic functions. | ||
* | ||
* This method handles calls to dynamic with helpers. | ||
*/ | ||
public static function __callStatic($method, $params) | ||
{ | ||
// No Compatibility Layer exists there; nothing to do. | ||
} | ||
|
||
/** | ||
* Compat Layer - Render a Module View file. | ||
* | ||
* @param string $path path to file from Modules folder | ||
* @param array $data array of data | ||
* @param array $error array of errors | ||
* | ||
* @throws \Exception | ||
*/ | ||
public static function renderModule($path, $data = false, $error = false) | ||
{ | ||
throw new \Exception('renderModule is not available on ' .static::class); | ||
} | ||
} |
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