diff --git a/packages/zend-controller/library/Zend/Controller/Action.php b/packages/zend-controller/library/Zend/Controller/Action.php index a7b4b953a..36664ed27 100644 --- a/packages/zend-controller/library/Zend/Controller/Action.php +++ b/packages/zend-controller/library/Zend/Controller/Action.php @@ -103,6 +103,12 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interfac * @var array */ public $contexts; + + /** + * Controller's ajax contexts, managed by Zend_Controller_Action_Helper_AjaxContext + * @var array + */ + public $ajaxable; /** * Class constructor diff --git a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php index 57d628825..1f4256966 100644 --- a/tests/Zend/Controller/Action/Helper/AjaxContextTest.php +++ b/tests/Zend/Controller/Action/Helper/AjaxContextTest.php @@ -159,6 +159,25 @@ public function tearDown() unset($_SERVER['HTTP_X_REQUESTED_WITH']); } } + + public function testAddActionContext() + { + // test covering PHP 8.2+ changes: + // Creation of dynamic property ::$ajaxable is deprecated + $controller = new Zend_Controller_Action_Helper_AjaxContextNoConfigTestController( + $this->request, + $this->response, + array() + ); + $this->helper->setActionController($controller); + + $this->helper + ->addActionContext('error', 'html') + ->initContext('html'); + + $actionContexts = $this->helper->getActionContexts('error'); + $this->assertEquals('html', $actionContexts[0]); + } public function testDefaultContextsIncludesHtml() { @@ -293,6 +312,10 @@ class Zend_Controller_Action_Helper_AjaxContextTestController extends Zend_Contr ); } +class Zend_Controller_Action_Helper_AjaxContextNoConfigTestController extends Zend_Controller_Action +{ +} + class Zend_Controller_Action_Helper_AjaxContextTest_LayoutOverride extends Zend_Layout { public static function resetMvcInstance()