當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TestController::setDI方法代碼示例

本文整理匯總了PHP中TestController::setDI方法的典型用法代碼示例。如果您正苦於以下問題:PHP TestController::setDI方法的具體用法?PHP TestController::setDI怎麽用?PHP TestController::setDI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TestController的用法示例。


在下文中一共展示了TestController::setDI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

<?php

/**
 * This is a Anax frontcontroller.
 *
 */
// Get environment & autoloader.
require __DIR__ . '/../config.php';
// Create services and inject into the app.
$di = new \Anax\DI\CDIFactoryTest();
$app = new \Anax\Kernel\CAnax($di);
$di->set('TestController', function () use($di) {
    $controller = new TestController();
    $controller->setDI($di);
    return $controller;
});
class TestController
{
    use \Anax\DI\TInjectable;
    public function indexAction()
    {
        $this->theme->setTitle("How verbose is the error reporting");
        $this->views->add('default/page', ['title' => "Testing error reporting from Anax MVC", 'content' => "Trying out some missusage of Anax MVC to see if the errors are easy to understand.", 'links' => [['href' => $this->url->create('t1'), 'text' => "Using not defined service as property of \$app"], ['href' => $this->url->create('t2'), 'text' => "Using not defined service as method of \$app"], ['href' => $this->url->create('t3'), 'text' => "Forward to non-existing controller"], ['href' => $this->url->create('t4'), 'text' => "Forward to non-existing action"], ['href' => $this->url->create('test/no-di-call'), 'text' => "Using TInjectable forgot to set \$di, accessing session() via __call()"], ['href' => $this->url->create('test/no-di-get'), 'text' => "Using TInjectable forgot to set \$di, accessing session via __get()"], ['href' => $this->url->create('test/no-such-service-property'), 'text' => "Using TInjectable forgot to set \$di, accessing session() via __call()"], ['href' => $this->url->create('test/no-such-service-method'), 'text' => "Using TInjectable forgot to set \$di, accessing session via __get()"]]]);
    }
    public function noDiCallAction()
    {
        $this->di = null;
        $this->session();
    }
    public function noDiGetAction()
    {
開發者ID:rcus,項目名稱:phpmvc,代碼行數:31,代碼來源:error-message-verbosity.php


注:本文中的TestController::setDI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。