/ Published in: PHP
quick access to frequently used instances
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php namespace Gateway\AppBundle\Common; use Symfony\Bundle\FrameworkBundle\Controller\Controller; trait ControllerPluginTrait { public function __construct() { if (!$this instanceof Controller) { } } public function getMongo() { return $this->get('doctrine_mongodb')->getManager(); } public function getUserRepository() { return $this->getMongo()->getRepository('Gateway\UserBundle\Document\User'); } public function getWorkspaceRepository() { return $this->getMongo()->getRepository('Gateway\UserBundle\Document\Workspace'); } public function getApplicationManager() { return $this->get('gateway.appmanager'); } }