当前位置: 首页>>代码示例>>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;未经允许,请勿转载。