PageRenderTime 80ms CodeModel.GetById 53ms app.highlight 2ms RepoModel.GetById 22ms app.codeStats 0ms

/zf/library/Zend/Dojo/View/Helper/DijitContainer.php

http://github.com/eryx/php-framework-benchmark
PHP | 92 lines | 32 code | 8 blank | 52 comment | 2 complexity | 06d6c8afe7519eaa0fdcf4660d55181f MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
 1<?php
 2/**
 3 * Zend Framework
 4 *
 5 * LICENSE
 6 *
 7 * This source file is subject to the new BSD license that is bundled
 8 * with this package in the file LICENSE.txt.
 9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category   Zend
16 * @package    Zend_Dojo
17 * @subpackage View
18 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20 * @version    $Id: DijitContainer.php 23775 2011-03-01 17:25:24Z ralph $
21 */
22
23/** Zend_Dojo_View_Helper_Dijit */
24require_once 'Zend/Dojo/View/Helper/Dijit.php';
25
26/**
27 * Dijit layout container base class
28 *
29 * @uses       Zend_Dojo_View_Helper_Dijit
30 * @package    Zend_Dojo
31 * @subpackage View
32 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license    http://framework.zend.com/license/new-bsd     New BSD License
34  */
35abstract class Zend_Dojo_View_Helper_DijitContainer extends Zend_Dojo_View_Helper_Dijit
36{
37    /**
38     * Capture locks
39     * @var array
40     */
41    protected $_captureLock = array();
42
43    /**
44     * Metadata information to use with captured content
45     * @var array
46     */
47    protected $_captureInfo = array();
48
49    /**
50     * Begin capturing content for layout container
51     *
52     * @param  string $id
53     * @param  array $params
54     * @param  array $attribs
55     * @return void
56     */
57    public function captureStart($id, array $params = array(), array $attribs = array())
58    {
59        if (array_key_exists($id, $this->_captureLock)) {
60            require_once 'Zend/Dojo/View/Exception.php';
61            throw new Zend_Dojo_View_Exception(sprintf('Lock already exists for id "%s"', $id));
62        }
63
64        $this->_captureLock[$id] = true;
65        $this->_captureInfo[$id] = array(
66            'params'  => $params,
67            'attribs' => $attribs,
68        );
69
70        ob_start();
71        return;
72    }
73
74    /**
75     * Finish capturing content for layout container
76     *
77     * @param  string $id
78     * @return string
79     */
80    public function captureEnd($id)
81    {
82        if (!array_key_exists($id, $this->_captureLock)) {
83            require_once 'Zend/Dojo/View/Exception.php';
84            throw new Zend_Dojo_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
85        }
86
87        $content = ob_get_clean();
88        extract($this->_captureInfo[$id]);
89        unset($this->_captureLock[$id], $this->_captureInfo[$id]);
90        return $this->_createLayoutContainer($id, $content, $params, $attribs);
91    }
92}