-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: Global context fix + added Renderer class
- Loading branch information
1 parent
8cf8b76
commit 95d1cd1
Showing
6 changed files
with
56 additions
and
25 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
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,36 @@ | ||
<?php | ||
|
||
namespace libraries; | ||
|
||
use Exception; | ||
|
||
/** | ||
* Renderer | ||
* | ||
* PHP Version 7.2 | ||
* | ||
* @category Renderer | ||
* @package hello-php | ||
* @author John Cyrill Corsanes <[email protected]> | ||
* @license http://opensource.org/licenses/MIT MIT License | ||
* @version v0.7.1-alpha | ||
* @link https://github.com/jcchikikomori/hello-php | ||
*/ | ||
class Renderer | ||
{ | ||
/** | ||
* Render partial file wihout checking layout switch | ||
* Note: Extracting arrays into variables are contained each view | ||
* | ||
* @param string $part = Partial view | ||
*/ | ||
public static function render_partial($part, $data = array()) | ||
{ | ||
extract($data); | ||
if (isset($GLOBALS["context"])) { | ||
include $GLOBALS['context']->getViewsPath() . $part . '.php'; | ||
} else { | ||
throw new Exception("Unable to locate the context."); | ||
} | ||
} | ||
} |
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