Last active
September 22, 2016 02:11
-
-
Save endam/0328f9b868a8a645b7d3e7775ff149e7 to your computer and use it in GitHub Desktop.
出力されたHTMLを見ただけで、CakephpのどのViewの内容なのかすぐに分かるようにする ref: http://qiita.com/endam/items/c8128efc487d027e01d0
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
<!-- START /var/www/html/sample/app/View/Samples/index.ctp --> | |
<div>サンプルだよ</div> | |
<!-- END /var/www/html/sample/app/View/Samples/index.ctp --> |
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->Sample->viewStartComment()?> | |
<div>サンプルだよ</div> | |
<?= $this->Sample->viewEndComment()?> |
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
/** | |
* View開始のHTMLコメント | |
*/ | |
function viewStartComment() | |
{ | |
return $this->viewComment(); | |
} | |
/** | |
* View終了のHTMLコメント | |
*/ | |
function viewEndComment() | |
{ | |
return $this->viewComment(true); | |
} | |
/** | |
* ViewのHTMLコメント出力共通処理 | |
*/ | |
private function viewComment($viewEnd = false) | |
{ | |
if (env("CAKE_ENV") !== "local"])) { | |
return ""; | |
} | |
$debugBackTrace = debug_backtrace(); | |
$viewPath = $debugBackTrace[1]["file"]; | |
$status = $viewEnd ? "END" : "START"; | |
return "<!-- {$status} {$viewPath} -->"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment