Exemple #1
0
<?php

use lasa\web\Application;
/*
 * home.php
 * @var $app lasa\web\Application
 */
$app = lasa\web\Application::getInstance();
$app->bind("get", function () {
    var_dump(Application::getInstance()->get("app.debug"));
    if (app_config("app.debug")) {
        echo "デバッグモードです";
    } else {
        echo "デバッグモードではありません";
    }
    echo "<hr />";
    echo date("Y-m-d H:i:s");
});
 function getContent($id, $tag, $inner, $attributes)
 {
     if ($tag == "form") {
         $attributes["action"] = '<?php $' . $this->_holderName . '->out("' . $id . '", $_SERVER["REQUEST_URI"]); ?>';
         $app = \lasa\web\Application::getInstance();
         if ($app) {
             $key = $app->option("csrf_key", "__csrf_token");
             $token = '<?php $app = \\lasa\\web\\Application::getInstance(); if($app){ echo $app->createToken("' . $id . '"); } ?>';
             $hiddenInput = '<input type="hidden" name="' . $key . '" value="' . $token . '" />';
             $inner = $hiddenInput . $inner;
         }
     }
     return parent::getContent($id, $tag, $inner, $attributes);
 }