Migrating 5.6.x helpers to 5.7

Permalink 1 user found helpful
Hi,

Apologies if this has been asked and answered elsewhere (I have searched extensively but can't find any info).

I am new to Concrete5 and am migrating a fairly simple 5.6 site to 5.7. I have started with a clean 5.7 install and am manually recreating the theme and pages.

The old site has some custom helper files in the helpers/ directory. The classes within the files are named like this:

class NavHelper {
...
}

I was hoping someone could give me some clear guidance on the correct way to migrate these to 5.7 as it looks like helpers have been overhauled.

Any help would be very much appreciated.

Zak

 
geertvdtol replied on at Permalink Reply
Hi Zak,

Did you find a solution for this yet? I am having the same problem. I can't figure out how to use custom helpers in concrete5 v5.7. Any help would be appreciated.
hissy replied on at Permalink Reply
hissy
Hi, here is an example.

1. Register a helper class to concrete5 in the application/bootstrap/app.php

Core::bind('helper/my_great_helper', function() {
    return new \Application\Src\MyGreatHelper();
});


2. Make a php file in the application directory

<?php
namespace Application\Src;
class MyGreatHelper
{
    public function getMessage()
    {
        return 'Hello!';
    }
}


application/src/MyGreatHelper.php

3. Use it

$helper = Core::make('helper/my_great_helper');
echo $helper->getMessage(); // Hello!
geertvdtol replied on at Permalink Reply
Hissy,
That's what I needed to know. Very clear answer. Thank you!
goutnet replied on at Permalink Reply
You should look at the "Like this block" addon from core (freely downloadable on the 5.7 marketplace).

It has the new best practices