E
E
Ernest Faizullin2016-04-04 22:51:03
Zend Framework
Ernest Faizullin, 2016-04-04 22:51:03

Overriding a function in Zend Framework?

How can you override the createData method in the Zend_View_Helper_HeadScript class without touching the framework core?
the class file itself is located in library/Zend/View/Helper/HeadScript.php, you need to slightly change the $attributes parameter:

class Zend_View_Helper_HeadScript extends Zend_View_Helper_Placeholder_Container_Standalone {
   ...
    public function createData($type, array $attributes, $content = null)
    {
        $data             = new stdClass();
        $data->type       = $type;
        $data->attributes = $attributes;
        $data->source     = $content;
        return $data;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2016-04-04
@erniesto77

Write your My_View_Helper_HeadScript, inheriting Zend_View_Helper_HeadScript. In it already override the createData method. RTFM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question