Override core block controllers within package

Hi community!

I have problem with overriding core block controller in my package. I used to have this override in root block folder, and it worked fine, but when I moved it do package it stopped to work. I assume that there is some problem with location of controller or/and with name of it. I couldn't find any naming conventions or advanced overriding tutorials so I'm asking for help.

Here's sytuation. I want to override tags controller. I had controller in root/blocks/tags/controller.php and as I said, it worked perfectly fine.

As I moved it do package I found out that it was working no longer. Tryied to move controller to packageName/controllers/blocks/tags/controller.php but it also didn't work.

So here's my question. How do I override core block controller in package?

Any kind of help appreciated

View Replies: View Best Answer
hutman replied on at Permalink Best Answer Reply
You have to use the override core by package.

The outer directory overrides _everything_ - including stuff in packages. You can make a custom template, and it will read that, but it's not overriding anything to do that, just parsing for available templates.

You want to put an on_start function like this in your package controller:

public function on_start() {
$objEnv = Environment::get();
$objEnv->overrideCoreByPackage('controllers/dashboard/composer/write.php', $this);
$objEnv->overrideCoreByPackage('single_pages/dashboard/composer/write.php', $this);
Lewiatan replied on at Permalink Reply
Thank You! Works great ;)
JohntheFish replied on at Permalink Reply
Just a head up, in case this is an idea for the marketplace.
At the moment the core team generally don't approve marketplace packages that override the core this way.
hutman replied on at Permalink Reply
Glad it works for you. You should totally mark it as 'best answer' ;)
Lewiatan replied on at Permalink Reply
Sorry, first time on this forum ;) Done ;)
hereNT replied on at Permalink Reply
FYI, this has been deprecated in 8.2 and no longer works. The Environment.php file says "Deprecated. Use Concrete\Core\Filesystem\FileLocator instead." Not sure how to do that, someone was asking about it in the Slack channel.
bleenders replied on at Permalink Reply
Found this out the hard way after upgrading to 8.2.
A little documentation on the matter won't hurt.