Express Form controller override
Permalink
I need some hard coded validation for all forms so I'm using the controller to output the error message if it fails.
The controller override works fine on PHP 5.6 but recently, I've upgraded my local machine to PHP 7.1.23 and I get the following error:
TypeError thrown with message "Argument 2 passed to Concrete\Core\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification::__construct() must be an instance of Concrete\Block\ExpressForm\Controller, instance of Application\Block\ExpressForm\Controller given, called in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php on line 97"
Stacktrace:
#26 TypeError in C:\xampp\htdocs\build1054\concrete\src\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification.php:14
#25 Concrete\Core\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification:__construct in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php:97
#24 Application\Block\ExpressForm\Controller:getNotifications in C:\xampp\htdocs\build1054\concrete\src\Express\Controller\StandardController.php:43
#23 Concrete\Core\Express\Controller\StandardController:getNotifier in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php:198
#22 Application\Block\ExpressForm\Controller:action_submit in C:\xampp\htdocs\build1054\concrete\src\Controller\AbstractController.php:294
#21 call_user_func_array in C:\xampp\htdocs\build1054\concrete\src\Controller\AbstractController.php:294
#20 Concrete\Core\Controller\AbstractController:runAction in C:\xampp\htdocs\build1054\concrete\src\Page\Controller\PageController.php:311
#19 Concrete\Core\Page\Controller\PageController:validateRequest in C:\xampp\htdocs\build1054\concrete\src\Http\ResponseFactory.php:175
#18 Concrete\Core\Http\ResponseFactory:controller in C:\xampp\htdocs\build1054\concrete\src\Http\ResponseFactory.php:393
#17 Concrete\Core\Http\ResponseFactory:collection in C:\xampp\htdocs\build1054\concrete\src\Routing\DispatcherRouteCallback.php:34
#16 Concrete\Core\Routing\DispatcherRouteCallback:execute in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultDispatcher.php:130
#15 Concrete\Core\Http\DefaultDispatcher:handleDispatch in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultDispatcher.php:57
#14 Concrete\Core\Http\DefaultDispatcher:dispatch in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\DispatcherDelegate.php:39
#13 Concrete\Core\Http\Middleware\DispatcherDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\ThumbnailMiddleware.php:71
#12 Concrete\Core\Http\Middleware\ThumbnailMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#11 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\FrameOptionsMiddleware.php:39
#10 Concrete\Core\Http\Middleware\FrameOptionsMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#9 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\CookieMiddleware.php:37
#8 Concrete\Core\Http\Middleware\CookieMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#7 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\ApplicationMiddleware.php:29
#6 Concrete\Core\Http\Middleware\ApplicationMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#5 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareStack.php:86
#4 Concrete\Core\Http\Middleware\MiddlewareStack:process in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultServer.php:85
#3 Concrete\Core\Http\DefaultServer:handleRequest in C:\xampp\htdocs\build1054\concrete\src\Foundation\Runtime\Run\DefaultRunner.php:119
#2 Concrete\Core\Foundation\Runtime\Run\DefaultRunner:run in C:\xampp\htdocs\build1054\concrete\src\Foundation\Runtime\DefaultRuntime.php:102
#1 Concrete\Core\Foundation\Runtime\DefaultRuntime:run in C:\xampp\htdocs\build1054\concrete\dispatcher.php:36
#0 require in C:\xampp\htdocs\build1054\index.php:3
The controller override works fine on PHP 5.6 but recently, I've upgraded my local machine to PHP 7.1.23 and I get the following error:
TypeError thrown with message "Argument 2 passed to Concrete\Core\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification::__construct() must be an instance of Concrete\Block\ExpressForm\Controller, instance of Application\Block\ExpressForm\Controller given, called in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php on line 97"
Stacktrace:
#26 TypeError in C:\xampp\htdocs\build1054\concrete\src\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification.php:14
#25 Concrete\Core\Express\Entry\Notifier\Notification\AbstractFormBlockSubmissionNotification:__construct in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php:97
#24 Application\Block\ExpressForm\Controller:getNotifications in C:\xampp\htdocs\build1054\concrete\src\Express\Controller\StandardController.php:43
#23 Concrete\Core\Express\Controller\StandardController:getNotifier in C:\xampp\htdocs\build1054\application\blocks\express_form\controller.php:198
#22 Application\Block\ExpressForm\Controller:action_submit in C:\xampp\htdocs\build1054\concrete\src\Controller\AbstractController.php:294
#21 call_user_func_array in C:\xampp\htdocs\build1054\concrete\src\Controller\AbstractController.php:294
#20 Concrete\Core\Controller\AbstractController:runAction in C:\xampp\htdocs\build1054\concrete\src\Page\Controller\PageController.php:311
#19 Concrete\Core\Page\Controller\PageController:validateRequest in C:\xampp\htdocs\build1054\concrete\src\Http\ResponseFactory.php:175
#18 Concrete\Core\Http\ResponseFactory:controller in C:\xampp\htdocs\build1054\concrete\src\Http\ResponseFactory.php:393
#17 Concrete\Core\Http\ResponseFactory:collection in C:\xampp\htdocs\build1054\concrete\src\Routing\DispatcherRouteCallback.php:34
#16 Concrete\Core\Routing\DispatcherRouteCallback:execute in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultDispatcher.php:130
#15 Concrete\Core\Http\DefaultDispatcher:handleDispatch in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultDispatcher.php:57
#14 Concrete\Core\Http\DefaultDispatcher:dispatch in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\DispatcherDelegate.php:39
#13 Concrete\Core\Http\Middleware\DispatcherDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\ThumbnailMiddleware.php:71
#12 Concrete\Core\Http\Middleware\ThumbnailMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#11 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\FrameOptionsMiddleware.php:39
#10 Concrete\Core\Http\Middleware\FrameOptionsMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#9 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\CookieMiddleware.php:37
#8 Concrete\Core\Http\Middleware\CookieMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#7 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\ApplicationMiddleware.php:29
#6 Concrete\Core\Http\Middleware\ApplicationMiddleware:process in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareDelegate.php:38
#5 Concrete\Core\Http\Middleware\MiddlewareDelegate:next in C:\xampp\htdocs\build1054\concrete\src\Http\Middleware\MiddlewareStack.php:86
#4 Concrete\Core\Http\Middleware\MiddlewareStack:process in C:\xampp\htdocs\build1054\concrete\src\Http\DefaultServer.php:85
#3 Concrete\Core\Http\DefaultServer:handleRequest in C:\xampp\htdocs\build1054\concrete\src\Foundation\Runtime\Run\DefaultRunner.php:119
#2 Concrete\Core\Foundation\Runtime\Run\DefaultRunner:run in C:\xampp\htdocs\build1054\concrete\src\Foundation\Runtime\DefaultRuntime.php:102
#1 Concrete\Core\Foundation\Runtime\DefaultRuntime:run in C:\xampp\htdocs\build1054\concrete\dispatcher.php:36
#0 require in C:\xampp\htdocs\build1054\index.php:3
I've already done that, you can see it in the error message where it says its expecting and instance of 'Concrete' and but an instance of 'Application' was given.
And the instance of Concrete/Blocks/*** still exists?
Yes
Sorry, I don't know the answer..
your overriding class, does it extend Concrete\Block\ExpressForm\Controller, as opposed to replace ?
if not, i would try making your class extending Concrete\Block\ExpressForm\Controller.
if not, i would try making your class extending Concrete\Block\ExpressForm\Controller.
How would I go about doing that, the class is the following.
class Controller extends BlockController implements NotificationProviderInterface
class Controller extends BlockController implements NotificationProviderInterface
use Concrete\Block\ExpressForm\Controller as befController; class Controller extends befController { ... }
Then your class is a subclass of befController, so any instance should also be instance of
Concrete\Block\ExpressForm\Controller
In your copied class you remove all properties and methods which you havent changed or added. Those are inherited from befController.
if you have changed a method, e.g. action_submit($bID = null), then inside your method you can have your code and then execute the befController code, like this
public function action_submit($bID = null) { ... do your stuff ... parent::action_submit($bID); }
seehttps://documentation.concrete5.org/developers/extending-concrete5-w...
To Application/blocks/***.
You should check the namespace of the overriden controller..
i.e. change it from
namespace Concrete\Block\ExpressForm;
to
namespace Application\Block\ExpressForm;