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


PHP Layout\Layout类代码示例

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


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

示例1: 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

示例2: getLayout

 /**
  * Retrieve layout object
  *
  * @return \Zend\Layout\Layout
  */
 public function getLayout()
 {
     if (null === $this->_layout) {
         $this->_layout = \Zend\Layout\Layout::startMvc($this->getOptions());
     }
     return $this->_layout;
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:12,代码来源:Layout.php

示例3: 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

示例4: disableLayouts

 /**
  * Disable layouts and view renderer
  *
  * @return \Zend\Controller\Action\Helper\AutoComplete\AbstractAutoComplete Provides a fluent interface
  */
 public function disableLayouts()
 {
     if (null !== ($layout = Layout::getMvcInstance())) {
         $layout->disableLayout();
     }
     HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
     return $this;
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:13,代码来源:AbstractAutoComplete.php

示例5: disableLayouts

 /**
  * Disable layouts and view renderer
  *
  * @return \Zend\Controller\Action\Helper\AutoComplete\AbstractAutoComplete Provides a fluent interface
  */
 public function disableLayouts()
 {
     if (null !== ($layout = Layout::getMvcInstance())) {
         $layout->disableLayout();
     }
     $this->getBroker()->load('viewRenderer')->setNoRender(true);
     return $this;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:AbstractAutoComplete.php

示例6: shutdown

    /**
     * Sends mail to recipient(s) if log entries are present.  Note that both
     * plaintext and HTML portions of email are handled here.
     *
     * @return void
     */
    public function shutdown()
    {
        // If there are events to mail, use them as message body.  Otherwise,
        // there is no mail to be sent.
        if (empty($this->_eventsToMail)) {
            return;
        }

        if ($this->_subjectPrependText !== null) {
            // Tack on the summary of entries per-priority to the subject
            // line and set it on the Zend_Mail object.
            $numEntries = $this->_getFormattedNumEntriesPerPriority();
            $this->_mail->setSubject(
                "{$this->_subjectPrependText} ({$numEntries})");
        }


        // Always provide events to mail as plaintext.
        $this->_mail->setBodyText(implode('', $this->_eventsToMail));

        // If a Zend_Layout instance is being used, set its "events"
        // value to the lines formatted for use with the layout.
        if ($this->_layout) {
            // Set the required "messages" value for the layout.  Here we
            // are assuming that the layout is for use with HTML.
            $this->_layout->events =
                implode('', $this->_layoutEventsToMail);

            // If an exception occurs during rendering, convert it to a notice
            // so we can avoid an exception thrown without a stack frame.
            try {
                $this->_mail->setBodyHtml($this->_layout->render());
            } catch (\Exception $e) {
                trigger_error(
                    "exception occurred when rendering layout; " .
                        "unable to set html body for message; " .
                        "message = {$e->getMessage()}; " .
                        "code = {$e->getCode()}; " .
                        "exception class = " . get_class($e),
                    E_USER_NOTICE);
            }
        }

        // Finally, send the mail.  If an exception occurs, convert it into a
        // warning-level message so we can avoid an exception thrown without a
        // stack frame.
        try {
            $this->_mail->send();
        } catch (\Exception $e) {
            trigger_error(
                "unable to send log entries via email; " .
                    "message = {$e->getMessage()}; " .
                    "code = {$e->getCode()}; " .
                        "exception class = " . get_class($e),
                E_USER_WARNING);
        }
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:63,代码来源:Mail.php

示例7: appBootstrap

 public function appBootstrap()
 {
     $this->frontController->setControllerDirectory(__DIR__ . '/_files/functional-test-app/controllers/');
     // create an instance of the ErrorHandler so we can make sure it will point to our specially named ErrorController
     $plugin = new \Zend\Controller\Plugin\ErrorHandler();
     $plugin->setErrorHandlerController('zend-layout-functional-test-error')->setErrorHandlerAction('error');
     $this->frontController->registerPlugin($plugin, 100);
     \Zend\Layout\Layout::startMvc(__DIR__ . '/_files/functional-test-app/layouts/');
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:9,代码来源:FunctionalTest.php

示例8: getLayout

 /**
  * Get layout object
  *
  * @return \Zend\Layout\Layout
  */
 public function getLayout()
 {
     if (null === $this->_layout) {
         $this->_layout = \Zend\Layout\Layout::getMvcInstance();
         if (null === $this->_layout) {
             // Implicitly creates layout object
             $this->_layout = new \Zend\Layout\Layout();
         }
     }
     return $this->_layout;
 }
开发者ID:rexmac,项目名称:zf2,代码行数:16,代码来源:Layout.php

示例9: 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()
 {
     Layout::resetMvcInstance();
     $this->request = new HTTPRequest();
     $this->response = new CLIResponse();
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->broker = $this->front->getHelperBroker();
     $this->viewRenderer = $this->broker->load('viewRenderer');
     $this->layout = Layout::startMvc();
 }
开发者ID:rexmac,项目名称:zf2,代码行数:18,代码来源:AutoCompleteTest.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()
 {
     Layout::resetMvcInstance();
     HelperBroker::resetHelpers();
     HelperBroker::setPluginLoader(null);
     $this->request = new HTTPRequest();
     $this->response = new CLIResponse();
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->viewRenderer = HelperBroker::getStaticHelper('viewRenderer');
     $this->layout = Layout::startMvc();
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:19,代码来源:AutoCompleteTest.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->markTestSkipped('Skipped until DOJO is converted to Zend\\Dojo');
     \Zend\Layout\Layout::resetMvcInstance();
     HelperBroker\HelperBroker::resetHelpers();
     HelperBroker\HelperBroker::setPluginLoader(null);
     $this->request = new \Zend\Controller\Request\HTTP();
     $this->response = new \Zend\Controller\Response\Cli();
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->viewRenderer = HelperBroker\HelperBroker::getStaticHelper('viewRenderer');
     $this->layout = Layout\Layout::startMvc();
 }
开发者ID:stunti,项目名称:zf2,代码行数:20,代码来源:AutoCompleteTest.php

示例12: __invoke

 /**
  * 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 __invoke($data, $keepLayouts = false)
 {
     $options = array();
     if (is_array($keepLayouts)) {
         $options = $keepLayouts;
         $keepLayouts = array_key_exists('keepLayouts', $keepLayouts) ? $keepLayouts['keepLayouts'] : false;
         unset($options['keepLayouts']);
     }
     $data = JsonFormatter::encode($data, null, $options);
     if (!$keepLayouts && $this->layout instanceof Layout) {
         $this->layout->disableLayout();
     }
     if ($this->response instanceof Response) {
         $headers = $this->response->headers();
         $headers->addHeaderLine('Content-Type', 'application/json');
     }
     return $data;
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:31,代码来源:Json.php

示例13: __invoke

 /**
  * 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 __invoke($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:bradley-holt,项目名称:zf2,代码行数:32,代码来源:Json.php

示例14: 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();
     HelperBroker\HelperBroker::resetHelpers();
     $this->front = Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules');
     $this->layout = Layout\Layout::startMvc();
     $this->helper = new Helper\ContextSwitch();
     HelperBroker\HelperBroker::addHelper($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(dirname(__FILE__));
     $this->view = new \Zend\View\View();
     $this->viewRenderer = HelperBroker\HelperBroker::getStaticHelper('viewRenderer');
     $this->viewRenderer->setView($this->view);
     $this->controller = new ContextSwitchTestController($this->request, $this->response, array());
     $this->controller->setupContexts();
     $this->helper->setActionController($this->controller);
 }
开发者ID:stunti,项目名称:zf2,代码行数:26,代码来源:ContextSwitchTest.php

示例15: prepareAutoCompletion

 /**
  * Prepare data for autocompletion
  *
  * @param  mixed   $data
  * @param  boolean $keepLayouts
  * @return string
  */
 public function prepareAutoCompletion($data, $keepLayouts = false)
 {
     if (!$data instanceof DojoData) {
         $items = array();
         foreach ($data as $key => $value) {
             $items[] = array('label' => $value, 'name' => $value);
         }
         $data = new DojoData('name', $items);
     }
     if (!$keepLayouts) {
         $this->getBroker()->load('viewRenderer')->setNoRender(true);
         $layout = Layout::getMvcInstance();
         if ($layout instanceof Layout) {
             $layout->disableLayout();
         }
     }
     $response = FrontController::getInstance()->getResponse();
     $response->setHeader('Content-Type', 'application/json');
     return $data->toJson();
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:27,代码来源:AutoCompleteDojo.php


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