How to override core block controller via Package

This is the request from a Japanese user.

He or she wants to override Content block’s controller from package.

It used to be a method overrideCoreByPackage. But it is deprecated since 8.2.

What is the alternative?

Hi @katz515 - does this do the trick?

@EvanCooper Thx.

But I’m afraid no.
He said he wants to override the core controller from package… not from application.

in the package’s on_start() method add

<?php
$this->app->bind(
    '\Concrete\Block\Image\Controller',
    '\Namespace\For\The\New\Image\Controller'
);

You have to do it that way in v9 because, for some reason, doing it the way below doesn’t work:

<?php
use Concrete\Block\Image\Controller as CoreImageController;
use Namespace\For\The\New\Image\Controller as ImageController;

$this->app->bind(
    CoreImageController::class,
    ImageController::class
);

That way works in v8 though

2 Likes

Oh cool.
Thanks!
I’ll let him know.