Overriding Calendar export class

Hi all,

I’m currently trying to override the calendar export class (old Outlook doesn’t recognize daylight savings when drag-and-dropping .ics files int old outook, offsetting calendar times by an hour). To do this, I need to add the VTIMEZONE block at the top of the generated .ics file. Easy enough by adding some extra code to the concrete/controllers/event/export.php file.

Of course, I don’t want to overwrite base concrete code, so I made a copy of the file in applications/controllers/event/export.php, changing the namespace from:

namespace Concrete\Controller\Event;

to

namespace Application\Controller\Event;

Then, to complete the override, I went into applications/bootstrap/app.php and added the following to the bottom of the comment block (as per the instructions in app.php):

Core::bind(‘\Concrete\Controller\Event\Export’, function($app, $params) {
return new \Application\Controller\Event\Export($params[0]);
});

Doing the above, my new code isn’t overriding the old code. Anyone know what I’m doing wrong?

Hello.
So first i’m assuming you added your code to the application folder (no “s”) and not applicationS like you wrote?

Try this instead:

$app->bind('\Concrete\Controller\Event\Export', '\Application\Controller\Event\Export'
);

Thanks for taking the time to reply!

I am using “application” singular. :slight_smile:

Tried the new binding method you suggested (adding it to bootstrap/app.js), unfortunately its also not working.

I think the problem is that we’re generating .ics files using a direct link on our events pages, with the links following this pattern:

%%our site%%/ccm/calendar/event/export?eventID=301

I don’t think the override above is working for these types of generated links. That’s my current theory at least…

I see in concrete/routes/calendar.php:

$router->all(‘/ccm/calendar/event/export’, ‘\Concrete\Controller\Event\Export::export’);

I wonder if I have to override this manually…

GOT IT!

What I needed to do was add to application/bootstrap/app.php:

$router = $app->make(‘router’);
$router->all(‘/ccm/calendar/event/export’, ‘\Application\Controller\Event\Export::export’);

That did it! Thanks for your help on this! You pointed me in the right direction.

Glad you figured it out.
Still, I’m surprised the overridden class doesn’t get called when the route is used. Technically the container should instantiate the class and hence use the override…

Oh well, I’m probably missing something…