ZF-10263: Unable to use startMvc() in a subclass of Zend_Layout due to use of 'self' keyword
Description
Test case:
<?php
class MyLayout extends Zend_Layout
{
}
$layout = MyLayout::startMvc();
echo get_class($layout);
Expected output: MyLayout
Actual output: Zend_Layout
This is due to the use of the 'self' keyword in startMvc() which statically binds to the Zend_Layout class, irrespective of any subclasses. More info: http://bugs.php.net/30934
Here's a patch, but it only works on PHP 5.3+ due to the use of get_called_class(). http://pastie.org/1075598
Comments
Posted by David (hndavid) on 2010-08-04T11:06:41.000+0000
couldn't find how to attach a file
Posted by Matthew Weier O'Phinney (matthew) on 2010-08-04T11:39:02.000+0000
You can actually override the behavior within versions of PHP prior to 5.3; you just need to copy and paste the methods "getMvcInstance()" and "startMvc()" into your subclass. Once you have, however, all calls to either My_Layout::getMvcInstance() or Zend_Layout::getMvcInstance() will return a My_Layout object as long as you started the session using My_Layout.
I've blogged about this type of extension previously: http://weierophinney.net/matthew/archives/…
In the meantime, we cannot make changes such as you suggest until 2.0, so I'm marking that as the fix version.
Posted by Matthew Weier O'Phinney (matthew) on 2010-08-04T11:39:23.000+0000
Scheduling for 2.0.
Posted by Adam Lundrigan (adamlundrigan) on 2012-03-14T00:24:01.000+0000
Will no be fixed in ZF1. No longer an issue with ZF2