Zend Framework Source Code Snippets

Zend_View_Helper_BundleFu

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
24
2526
27
28
29
3031
32
33
34
3536
37
38
39
4041
42
43
44
4546
47
48
49
5051
52
53
54
5556
57
58
59
6061
62
63
64
6566
67
68
69
7071
72
73
74
7576
77
78
79
8081
82
83
84
8586
87
88
89
9091
92
93
94
9596
97
98
99
100101
102
103
104
105106
107
108
109
110111
112
113
114
115116
117
118
119
120121
122
123
124
125126
127
128
129
130131
132
133
134
135136
137
138
139
140
<?php
/**
 * Du
 *
 * LICENSE *
 * This source file is subject to the BSD license that is available
 * through the world-wide-web at this URL:
 * http://opensource.org/licenses/bsd-license.php
 * * @category   Du
 * @package    Du_BundleFu
 * @subpackage Integration
 * @copyright  Copyright (C) 2010 - Present, Jan Sorgalla
 * @license    BSD License {@link http://www.opensource.org/licenses/bsd-license.php} */
 
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
 /**
 * Zend_View_Helper_BundleFu
 *
 * @category   Du
 * @package    Du_BundleFu * @subpackage Integration
 * @author     Jan Sorgalla
 * @copyright  Copyright (C) 2010 - Present, Jan Sorgalla
 * @license    BSD License {@link http://www.opensource.org/licenses/bsd-license.php}
 */class Zend_View_Helper_BundleFu extends Zend_View_Helper_Abstract
{
    /**
     * @var \Du\BundleFu\BundleFu
     */    protected $_bundleFu;
 
    /**
     * Set the BundleFu instance
     *      * @param \Du\BundleFu\BundleFu $bundleFu
     * @return Zend_View_Helper_BundleFu
     */
    public function setBundleFu(\Du\BundleFu\BundleFu $bundleFu)
    {        $this->_bundleFu = $bundleFu;
        return $this;
    }
 
    /**     * Get the BundleFu instance
     *
     * @return \Du\BundleFu\BundleFu
     */
    public function getBundleFu()    {
        if (null === $this->_bundleFu) {
            $this->_bundleFu = new \Du\BundleFu\BundleFu();
        }
         return $this->_bundleFu;
    }
 
    /**
     * @return Zend_View_Helper_BundleFu     */
    public function bundleFu()
    {
        return $this;
    } 
    /**
     * @param string $method
     * @param array $params
     * @return mixed     */
    public function __call($method, $params)
    {
        $return = call_user_func_array(array($this->getBundleFu(), $method), $params);
         switch ($method) {
            case 'start':
            case 'end':
            case substr($method, 0, 3) == 'set':
                return $this;            default:
                return $return;
        }
    }
     /**
     * @return string
     */
    public function __toString()
    {        try {
            $return = $this->getBundleFu()->render();
            return $return;
        } catch (\Exception $e) {
            trigger_error($e->getMessage(), E_USER_WARNING);            return '';
        }
    }
 
    /**     * @param Zend_View_Helper_HeadLink $helper
     * @return Zend_View_Helper_BundleFu 
     */
    public function bundleHeadLink(Zend_View_Helper_HeadLink $helper)
    {        $bundleFu = $this->getBundleFu();
 
        foreach ($helper->getArrayCopy() as $key => $item) {
            if (isset($item->href)) {
                $bundleFu->getCssFileList()->addFile($item->href, $bundleFu->getDocRoot() . $item->href);                unset($helper[$key]);
            }
        }
 
        return $this;    }
 
    /**
     * @param Zend_View_Helper_HeadScript $helper
     * @return Zend_View_Helper_BundleFu      */
    public function bundleHeadScript(Zend_View_Helper_HeadScript $helper)
    {
        $bundleFu = $this->getBundleFu();
         foreach ($helper->getArrayCopy() as $key => $item) {
            if (isset($item->attributes['src'])) {
                $bundleFu->getJsFileList()->addFile($item->attributes['src'], $bundleFu->getDocRoot() . $item->attributes['src']);
                unset($helper[$key]);
            }        }
 
        return $this;
    }
}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

Zend_View_Helper_BundleFu is a view helper integrating Du_BundeFu into your Zend Framework applications.

Du_BundleFu repo:
http://github.com/dotsunited/du-bundlefu

Installation instructions for Zend_View_Helper_BundleFu:
http://github.com/dotsunited/du-bundlefu/tree/master/integration/zf1/

Snippet details

Created:
jsor jsor
1 year ago
Edited:
jsor jsor
1 year ago
Revision Id:
176
Edit Message:
ZF Version
1.10.7
Tags:
view helper css js bundle
Comments:
0
Views:
3723
Points:
1 (1 votes)

History

r176

jsor jsor
1 year ago
diff
r175

Initial Release

jsor jsor
1 year ago
diff
r174

Initial Release

jsor jsor
1 year ago
diff
r170

Initial Release

jsor jsor
1 year ago