Last active
December 24, 2015 09:18
-
-
Save gnutix/6775868 to your computer and use it in GitHub Desktop.
Example of command that depends on the "framework.templating.assets_version" configuration value.
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 Acme\DemoBundle\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
/** | |
* assets_version dependent command | |
*/ | |
class AcmeAssetsVersionDependentCommand extends ContainerAwareCommand | |
{ | |
/** | |
* {@inheritDoc} | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$this->getContainer()->enterScope('request'); | |
$this->getContainer()->set('request', new Request()); | |
$version = $this->getContainer()->get('templating.helper.assets')->getVersion(); | |
$this->getContainer()->leaveScope('request'); | |
// use $version | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment