Generate $app->make in 5.7
Permalink
I am working on a package that is to be compatible with 5.7 and 5.8.
As core::make is now deprecated, I am trying to use $app->make. I am getting errors when testing in 5.7, but it works in 5.8.
However, I understand that I need to generate $app. How do I do this?
As core::make is now deprecated, I am trying to use $app->make. I am getting errors when testing in 5.7, but it works in 5.8.
However, I understand that I need to generate $app. How do I do this?
This is what I currently have in my block controller:
It works in 5.8, but not 5.7. In the error console, this is throwing the error:
public function on_start() { $this->set('app', $this->app); }
It works in 5.8, but not 5.7. In the error console, this is throwing the error:
return (empty($linkToC) || $linkToC->error) ? '' : $this->app->make('helper/navigation')->getLinkToCollection($linkToC);
That is because $this->app is not defined in 5.7, hence the condition above which essentially says if $this->app doesn't exist yet, then create it, so it adapts between v8 and 5.7.
I'm lost. Here's what I have for the on_start:
I've also tried:
To be honest, I have no idea what to do here.
public function on_start() { if(!is_object($this->app)){ $this->app = new $this->app->make('helper/navigation'); } }
I've also tried:
public function on_start() { if(!is_object($this->app)){ $this->app = new $this->set('app', $this->app); } }
To be honest, I have no idea what to do here.
Try:
https://documentation.concrete5.org/developers/appendix/concrete5-ve...
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
https://documentation.concrete5.org/developers/appendix/concrete5-ve...
public function on_start() { if(!is_object($this->app)){ $this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); $this->set('app', $this->app); } }
This works fine in 5.7, but it fails in 5.8. In 5.8 when trying to edit a block, the form dialog never loads and doesn't open.
I think I will just stick with Core::make, since it works just fine on both versions.
I think I will just stick with Core::make, since it works just fine on both versions.
I use this in several packages compatible with both 5.7 and 8 (there is no 5.8) and it works just fine, you might have something else at play here? Check your Logs for an exact error message.
As far as the PRB is concerned, I don't think getting rid of Core is open to discussion. We've been making everybody get rid of it.
I can be wrong though, better check in the PRB.
As far as the PRB is concerned, I don't think getting rid of Core is open to discussion. We've been making everybody get rid of it.
I can be wrong though, better check in the PRB.
I had to change the code in order to get the 'app' variable sent to the form.
This is the change I made:
This is the change I made:
public function on_start() { if(!is_object($this->app)){ $this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); } $this->set('app', $this->app); }
The code can also be run in a __construct() method, but if you do that be sure to get the parameters right and call the parent.