当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller\Front类代码示例

本文整理汇总了PHP中Zend\Controller\Front的典型用法代码示例。如果您正苦于以下问题:PHP Front类的具体用法?PHP Front怎么用?PHP Front使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Front类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

    public function setUp()
    {
        date_default_timezone_set('America/Los_Angeles');

        // Reset front controller to reset registered plugins and
        // registered request/response objects
        \Zend\Controller\Front::getInstance()->resetInstance();

        $this->_request = new FirePhpHeader();
        $this->_response = new MockHttpResponse();

        $channel = Channel\HttpHeaders::getInstance();
        $channel->setRequest($this->_request);
        $channel->setResponse($this->_response);

        $this->_writer = new FirebugWriter();

        // Explicitly enable writer as it is disabled by default
        // when running from the command line.
        $this->_writer->setEnabled(true);

        $this->_logger = new Logger($this->_writer);

        FirePhp::getInstance()->setOption('includeLineNumbers', false);
    }
开发者ID:rkeplin,项目名称:zf2,代码行数:25,代码来源:FirebugTest.php

示例2: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->request = new Request\Http();
     $this->front->setRequest($this->request);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:ActionStackTest.php

示例3: setUp

    protected function setUp()
    {
        if (!extension_loaded('pdo_sqlite')) {
           $this->markTestSkipped('Pdo_Sqlite extension is not loaded');
        }

        $this->_adapter = new \Zend\Db\Adapter\Pdo\Sqlite(array(
            'dbname' => __DIR__ . '/_files/test.sqlite'
        ));

        $this->_query = $this->_adapter->select()->from('test');

        $this->_testCollection = range(1, 101);
        $this->_paginator = Paginator\Paginator::factory($this->_testCollection);

        $this->_config = new Config\Xml(__DIR__ . '/_files/config.xml');
        // get a fresh new copy of ViewRenderer in each tests
        $this->front = FrontController::getInstance();
        $this->front->resetInstance();
        $this->broker = $this->front->getHelperBroker();

        $fO = array('lifetime' => 3600, 'automatic_serialization' => true);
        $bO = array('cache_dir'=> $this->_getTmpDir());

        $this->_cache = \Zend\Cache\Cache::factory('Core', 'File', $fO, $bO);

        Paginator\Paginator::setCache($this->_cache);

        $this->_restorePaginatorDefaults();
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:30,代码来源:PaginatorTest.php

示例4: init

 public function init()
 {
     $this->_front = \Zend\Controller\Front::getInstance();
     if ($this->_front->hasPlugin('Zend\\Layout\\Controller\\Plugin\\Layout')) {
         $this->_layout = $this->_front->getPlugin('Zend\\Layout\\Controller\\Plugin\\Layout')->getLayout();
     }
 }
开发者ID:zendmaniacs,项目名称:zly-templater,代码行数:7,代码来源:Widget.php

示例5: setUp

 protected function setUp()
 {
     $this->_originaltimezone = date_default_timezone_get();
     date_default_timezone_set('Europe/Berlin');
     if (isset($_SERVER['SERVER_NAME'])) {
         $this->_oldServer['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
     }
     if (isset($_SERVER['SERVER_PORT'])) {
         $this->_oldServer['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
     }
     if (isset($_SERVER['REQUEST_URI'])) {
         $this->_oldServer['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
     }
     $_SERVER['SERVER_NAME'] = 'localhost';
     $_SERVER['SERVER_PORT'] = 80;
     $_SERVER['REQUEST_URI'] = '/';
     $this->_front = \Zend\Controller\Front::getInstance();
     $this->_oldRequest = $this->_front->getRequest();
     $this->_oldRouter = $this->_front->getRouter();
     $this->_front->resetInstance();
     $this->_front->setRequest(new Request\Http());
     $this->_front->getRouter()->addDefaultRoutes();
     parent::setUp();
     $this->_helper->setFormatOutput(true);
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:25,代码来源:SitemapTest.php

示例6: direct

    /**
     * Encode data as JSON, disable layouts, and set response header
     *
     * If $keepLayouts is true, does not disable layouts.
     *
     * @param  mixed $data
     * @param  bool $keepLayouts
     * NOTE:   if boolean, establish $keepLayouts to true|false
     *         if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
     *         this array can contains a 'keepLayout'=>true|false
     *         that will not be passed to Zend_Json::encode method but will be used here
     * @return string|void
     */
    public function direct($data = null, $keepLayouts = false)
    {
        if ($data == null) {
            throw new \InvalidArgumentException('JSON: missing argument. $data is required in json($data, $keepLayouts = false)');
        }
        
        $options = array();
        if (is_array($keepLayouts))
        {
            $options     = $keepLayouts;
            $keepLayouts = (array_key_exists('keepLayouts', $keepLayouts))
                            ? $keepLayouts['keepLayouts']
                            : false;
            unset($options['keepLayouts']);
        }

        $data = \Zend\Json\Json::encode($data, null, $options);
        if (!$keepLayouts) {
            $layout = LayoutManager::getMvcInstance();
            if ($layout instanceof LayoutManager) {
                $layout->disableLayout();
            }
        }

        $response = \Zend\Controller\Front::getInstance()->getResponse();
        $response->setHeader('Content-Type', 'application/json');
        return $data;
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:41,代码来源:Json.php

示例7: setUp

    public function setUp()
    {
        $front = \Zend\Controller\Front::getInstance();
        $front->resetInstance();
        $front->setParam('noErrorHandler', true)
              ->setParam('noViewRenderer', true);

        $this->_dispatcher = $front->getDispatcher();

        $this->_dispatcher->setControllerDirectory(array(
            'default' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files',
            'mod'     => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin',
        ));

        $defaults = array(
            'controller' => 'defctrl',
            'action'     => 'defact',
            'module'     => 'default'
        );

        $this->_request = new \Zend\Controller\Request\Http();
        $front->setRequest($this->_request);

        $this->route = new Route\Module($defaults, $this->_dispatcher, $this->_request);
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:25,代码来源:ModuleTest.php

示例8: __invoke

 /**
  * Renders a template fragment within a variable scope distinct from the
  * calling View object.
  *
  * If no arguments are passed, returns the helper instance.
  *
  * If the $model is an array, it is passed to the view object's assign()
  * method.
  *
  * If the $model is an object, it first checks to see if the object
  * implements a 'toArray' method; if so, it passes the result of that
  * method to to the view object's assign() method. Otherwise, the result of
  * get_object_vars() is passed.
  *
  * @param  string $name Name of view script
  * @param  string|array $module If $model is empty, and $module is an array,
  *                              these are the variables to populate in the
  *                              view. Otherwise, the module in which the
  *                              partial resides
  * @param  array $model Variables to populate in the view
  * @return string|\Zend\View\Helper\Partial\Partial
  * @throws Exception\RuntimeException
  */
 public function __invoke($name = null, $module = null, $model = null)
 {
     if (0 == func_num_args()) {
         return $this;
     }
     $view = $this->cloneView();
     if (isset($this->partialCounter)) {
         $view->partialCounter = $this->partialCounter;
     }
     if (null !== $module && is_string($module)) {
         $moduleDir = \Zend\Controller\Front::getInstance()->getControllerDirectory($module);
         if (null === $moduleDir) {
             throw new Exception\RuntimeException('Cannot render partial; module does not exist');
         }
         $viewsDir = dirname($moduleDir) . '/views';
         $view->resolver()->addPath($viewsDir . '/scripts');
     } elseif (null == $model && null !== $module && (is_array($module) || is_object($module))) {
         $model = $module;
     }
     if (!empty($model)) {
         if (is_array($model)) {
             $view->vars()->assign($model);
         } elseif (is_object($model)) {
             if (null !== ($objectKey = $this->getObjectKey())) {
                 $view->vars()->offsetSet($objectKey, $model);
             } elseif (method_exists($model, 'toArray')) {
                 $view->vars()->assign($model->toArray());
             } else {
                 $view->vars()->assign(get_object_vars($model));
             }
         }
     }
     return $view->render($name);
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:57,代码来源:Partial.php

示例9: setUp

 public function setUp()
 {
     $this->application = new Application('testing');
     $this->bootstrap = new ZfAppBootstrap($this->application);
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:7,代码来源:ModulesTest.php

示例10: setUp

    /**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     *
     * @return void
     */
    public function setUp()
    {
        \Zend\Layout\Layout::resetMvcInstance();

        $this->front = Controller\Front::getInstance();
        $this->front->resetInstance();
        $this->front->addModuleDirectory(__DIR__ . '/../../_files/modules');
        $this->broker = $this->front->getHelperBroker();

        $this->layout = Layout\Layout::startMvc();

        $this->helper = new Helper\ContextSwitch();
        $this->broker->register('contextswitch', $this->helper);

        $this->request = new \Zend\Controller\Request\Http();
        $this->response = new \Zend\Controller\Response\Cli();

        $this->front->setRequest($this->request)
                    ->setResponse($this->response)
                    ->addControllerDirectory(__DIR__);

        $this->view = new \Zend\View\PhpRenderer();
        $this->viewRenderer = $this->broker->load('viewRenderer');
        $this->viewRenderer->setView($this->view);

        $this->controller = new ContextSwitchTestController(
            $this->request,
            $this->response,
            array()
        );
        $this->controller->setHelperBroker($this->broker);
        $this->controller->setupContexts();
        $this->helper->setActionController($this->controller);
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:40,代码来源:ContextSwitchTest.php

示例11: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest(new \Zend\Controller\Request\Http());
     $this->helper = new \Zend\Controller\Action\Helper\Url();
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:UrlTest.php

示例12: setUp

 public function setUp()
 {
     $this->application = new Application\Application('testing');
     $this->bootstrap = new Application\Bootstrap($this->application);
     $this->bootstrap->getBroker()->registerSpec('view');
     FrontController::getInstance()->resetInstance();
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:7,代码来源:DojoTest.php

示例13: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     \Zend\Controller\Front::getInstance()->resetInstance();
     $this->request = new \Zend\Controller\Request\HttpTestCase();
     $this->plugin = new \Zend\Controller\Plugin\PutHandler();
     $this->plugin->setRequest($this->request);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:PutHandlerTest.php

示例14: setUp

 public function setUp()
 {
     $this->_front = FrontController::getInstance();
     $this->_front->resetInstance();
     $this->_front->setParam('noErrorHandler', true)->setParam('noViewRenderer', true);
     $this->_dispatcher = $this->_front->getDispatcher();
     $this->_dispatcher->setControllerDirectory(array('default' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . '_files', 'mod' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin'));
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:8,代码来源:RouteTest.php

示例15: setUp

 public function setUp()
 {
     $this->application = new Application('testing', array('resources' => array('frontcontroller' => array())));
     $this->bootstrap = new ZfAppBootstrap($this->application);
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
     $this->broker = $this->front->getHelperBroker();
 }
开发者ID:RomanShumkov,项目名称:zf2,代码行数:8,代码来源:ViewTest.php


注:本文中的Zend\Controller\Front类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。