Skip to content

Instantly share code, notes, and snippets.

@thunderer
Last active December 14, 2015 21:19
Show Gist options
  • Save thunderer/5150082 to your computer and use it in GitHub Desktop.
Save thunderer/5150082 to your computer and use it in GitHub Desktop.
Naming convention for local bundle controller base class.
<?php
namespace Thunder\Bundle\SthBundle;
use Symfony\Bundle\FrameworkBundle\Controller\Controller as ControllerBase;
class Controller extends ControllerBase
{
public function usefulToolThatDoesNotFitIntoService()
{
return $computedUsefulValue;
}
public function anotherBundleWideToolSharedAmongControllers()
{
return $anotherUsefulValue;
}
public function getRandomValue()
{
return 4; // based on a fair dice roll
}
}
<?php
namespace Thunder\Bundle\SthBundle;
// using local namespace resolving, one `use` statement less
class SthController extends Controller
{
public function indexAction()
{
$view = array();
$view['foo'] = $this->usefulToolThatDoesNotFitIntoService();
$view['bar'] = $this->anotherBundleWideToolSharedAmongControllers();
return $this->render('template', $view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment