Example #1
0
 public function testServices()
 {
     $ins = getAuth();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Auth\IAuth::class, $ins);
     $ins = getView();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\IView::class, $ins);
     $ins = getLog();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Log\ILog::class, $ins);
     //        $ins = getDB();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\MedooDB::class, $ins);
     //        $ins = getRedis();
     //        $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\PRedis::class, $ins);
     //        $ins = getDataPool();
     //        $this->assertInstanceOf(\Wwtg99\DataPool\Common\IDataPool::class, $ins);
     $ins = getCache();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\Cache::class, $ins);
     $ins = getSession();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\SessionUtil::class, $ins);
     $ins = getCookie();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\CookieUtil::class, $ins);
     $ins = getOValue();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\OldValue::class, $ins);
     $ins = getAssets();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\AssetsManager::class, $ins);
     $ins = getMailer();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Mail::class, $ins);
     $ins = Flight::Express();
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Express::class, $ins);
     $ins = getPlugin('php');
     $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Plugin\IPlugin::class, $ins);
 }
Example #2
0
<?php
    include ('lib/rb.php');
    include ('lib/animation.class.php');
    include ('lib/asset.class.php');
    include ('lib/config.php');

    R::setup ("mysql:host={$cfg['db_host']};dbname=stickStudio;", $cfg['db_user'], $cfg['db_pass']);

    function getAssets ($i) {
        $anim = new Animation ($i);

        foreach ($anim->getAssets () as $asset) {
            echo $asset->name;
        }
    }

    if (isset ($_GET['asset_animation'])) {
        getAssets ($_GET['asset_animation']);
    }

?>
Example #3
0
 /**
  * Add twig extended functions
  */
 protected function addFunctions()
 {
     // isDebug
     $func = new \Twig_SimpleFunction('isDebug', function () {
         return isDebug();
     });
     $this->twig->addFunction($func);
     // debugbarHead
     $func = new \Twig_SimpleFunction('debugbarHead', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             $debugRender->setBaseUrl(U('assets/debugbar'));
             return $debugRender->renderHead();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderDubugbar
     $func = new \Twig_SimpleFunction('renderDebugbar', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             return $debugRender->render();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderAssets
     $func = new \Twig_SimpleFunction('renderAssets', function ($addlib = []) {
         $ass = getAssets();
         if ($addlib) {
             $ass->addLibrary($addlib);
         }
         return $ass->renderCss() . $ass->renderJs();
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // get resource
     $func = new \Twig_SimpleFunction('resource', function ($name, $prefix = '') {
         return getAssets()->getResource($name, $prefix);
     });
     $this->twig->addFunction($func);
     // isLogin
     $func = new \Twig_SimpleFunction('isLogin', function () {
         return getAuth()->isLogin();
     });
     $this->twig->addFunction($func);
     // isSuperuser
     $func = new \Twig_SimpleFunction('isSuperuser', function () {
         return getAuth()->isSuperuser();
     });
     $this->twig->addFunction($func);
     // hasRole
     $func = new \Twig_SimpleFunction('hasRole', function ($role) {
         return getAuth()->hasRole($role);
     });
     $this->twig->addFunction($func);
     // getConfig
     $func = new \Twig_SimpleFunction('getConfig', function ($name) {
         return \Flight::get('config')->get($name);
     });
     $this->twig->addFunction($func);
     // getUser
     $func = new \Twig_SimpleFunction('getUser', function () {
         return getAuth()->getUser();
     });
     $this->twig->addFunction($func);
     // old value
     $func = new \Twig_SimpleFunction('old', function ($name, $def = '') {
         return getOld($name, $def);
     });
     $this->twig->addFunction($func);
     // log
     $func = new \Twig_SimpleFunction('log', function ($level, $msg, $context = []) {
         return getLog()->log($level, $msg, $context);
     });
     $this->twig->addFunction($func);
 }