Last active
December 14, 2015 21:19
-
-
Save thunderer/5150082 to your computer and use it in GitHub Desktop.
Naming convention for local bundle controller base class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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