__constructs() conflicts with extends PageController

I’m developing a single page and I want to define my connection just like this page does Accessing the Database to Make Queries

However the __construct triggers the error “Call to a member function getCollectionPath() on null”

Here is my code, stripped down, it’s literally just construct and then render a view, and even then it gives the same error.

namespace Application\Controller\SinglePage;
use Concrete\Core\Page\Controller\PageController;
use Core;
use Loader;
use Page;
use Concrete\Core\File\File;

class Agenda extends PageController
	public $app;
	public $config;

	public function __construct()
		$this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
		$this->config = $this->app->make('config');

	public function view()

I’ve made a working __construct() in a block controller and there it worked. So I think it conflicts with PageController. Does anyone know a solution?


Where the parent also has a construct, you need to call parent::_construct() to make sure nothing the parent set up gets left out.

Ah good catch didn’t know I needed to do that.

I added parent::__construct(); right above $this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();. I now got a new error:

Too few arguments to function Concrete\Core\Page\Controller\PageController::_construct(), 0 passed in FULL_PATH_HERE/application/controllers/single_page/agenda.php on line 23 and exactly 1 expected.

So parent::__construct(); requires an argument. What do I need to put there?

Look at the source for Concrete\Core\Page\Controller\PageController.

Thanks for the hint. I ended up getting it to work with

public function __construct(Connection $connection, Page $c)