1

I have updated my cakePHP application to 3.1 through composer, and I'm trying to fix all the small or deprecated warnings.

I could easily fix the $this->layout stuff but I don't understand how to fix viewPath errors.

Looking at the migration guide it looks like it should be exactly the same thing:

$this->viewPath = 'Element';

should become

$this->viewBuilder()->viewPath('Element');

But this is not working, and the only thing that I get is

Error: Call to undefined method Cake\View\ViewBuilder::viewPath() 
File /var/www/myapp/src/Controller/InvoicesController.php 
Line: 375

What is the correct way to fix this?

ToX 82
  • 1,064
  • 12
  • 35

1 Answers1

4

From the very same migration guide, in the View section of it:

View::$viewPath is deprecated. You should use View::templatePath() instead.

Guess it's now:

$this->viewBuilder()->templatePath('Element');
floriank
  • 25,546
  • 9
  • 42
  • 66