08/10
2014
dev-master
9999999-devController component for WordPress
The Development Requires
Controller component for WordPress
$pimple["pageController"] = function ($c) { return new PageController($c); };
class PageController extends AbstractController { public function indexAction($request) { echo "This is the index action for the PageController"; } }
You can also extend the AbstractTimberController which adds the render method that uses Timber/Twig to render the given template with the context., (*2)
class PageController extends AbstractTimberController { public function indexAction($request) { $context = \Timber::get_context(); $this->render('page.twig', $context); } }
Finally you will want to use the DIC on the controller to access various data and services, you can do this via the dic property of the controller:, (*3)
public function indexAction($request) { $context = \Timber::get_context(); $context["searchManager"] = $this->dic["searchManager"]; $this->render('page.twig', $context); }
Controller component for WordPress