Skip to content

Instantly share code, notes, and snippets.

@gnutix
Last active December 24, 2015 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnutix/6775868 to your computer and use it in GitHub Desktop.
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.
<?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