init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
65
vendor/doctrine/doctrine-cache-bundle/Command/CacheCommand.php
vendored
Normal file
65
vendor/doctrine/doctrine-cache-bundle/Command/CacheCommand.php
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
/**
|
||||
* Base cache command.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
abstract class CacheCommand extends Command implements ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* Get the requested cache provider service.
|
||||
*
|
||||
* @param string $cacheName
|
||||
*
|
||||
* @return \Doctrine\Common\Cache\Cache
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function getCacheProvider($cacheName)
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
|
||||
// Try to use user input as cache service alias.
|
||||
$cacheProvider = $container->get($cacheName, ContainerInterface::NULL_ON_INVALID_REFERENCE);
|
||||
|
||||
// If cache provider was not found try the service provider name.
|
||||
if ( ! $cacheProvider instanceof Cache) {
|
||||
$cacheProvider = $container->get('doctrine_cache.providers.' . $cacheName, ContainerInterface::NULL_ON_INVALID_REFERENCE);
|
||||
}
|
||||
// Cache provider was not found.
|
||||
if ( ! $cacheProvider instanceof Cache) {
|
||||
throw new \InvalidArgumentException('Cache provider not found.');
|
||||
}
|
||||
|
||||
return $cacheProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
||||
40
vendor/doctrine/doctrine-cache-bundle/Command/ContainsCommand.php
vendored
Normal file
40
vendor/doctrine/doctrine-cache-bundle/Command/ContainsCommand.php
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Check if a cache entry exists.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class ContainsCommand extends CacheCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('doctrine:cache:contains')
|
||||
->setDescription('Check if a cache entry exists')
|
||||
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to use?')
|
||||
->addArgument('cache-id', InputArgument::REQUIRED, 'Which cache ID to check?');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$cacheName = $input->getArgument('cache-name');
|
||||
$cacheProvider = $this->getCacheProvider($cacheName);
|
||||
$cacheId = $input->getArgument('cache-id');
|
||||
|
||||
$message = $cacheProvider->contains($cacheId) ? '<info>TRUE</info>' : '<error>FALSE</error>';
|
||||
$output->writeln($message);
|
||||
}
|
||||
}
|
||||
64
vendor/doctrine/doctrine-cache-bundle/Command/DeleteCommand.php
vendored
Normal file
64
vendor/doctrine/doctrine-cache-bundle/Command/DeleteCommand.php
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Delete cache entries.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class DeleteCommand extends CacheCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('doctrine:cache:delete')
|
||||
->setDescription('Delete a cache entry')
|
||||
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to use?')
|
||||
->addArgument('cache-id', InputArgument::OPTIONAL, 'Which cache ID to delete?')
|
||||
->addOption('all', 'a', InputOption::VALUE_NONE, 'Delete all cache entries in provider');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$cacheName = $input->getArgument('cache-name');
|
||||
$cacheProvider = $this->getCacheProvider($cacheName);
|
||||
$cacheId = $input->getArgument('cache-id');
|
||||
$all = $input->getOption('all');
|
||||
|
||||
if ($all && ! method_exists($cacheProvider, 'deleteAll')) {
|
||||
throw new \RuntimeException('Cache provider does not implement a deleteAll method.');
|
||||
}
|
||||
|
||||
if ( ! $all && ! $cacheId) {
|
||||
throw new \InvalidArgumentException('Missing cache ID');
|
||||
}
|
||||
|
||||
$success = $all ? $cacheProvider->deleteAll() : $cacheProvider->delete($cacheId);
|
||||
$color = $success ? 'info' : 'error';
|
||||
$success = $success ? 'succeeded' : 'failed';
|
||||
$message = null;
|
||||
|
||||
if ( ! $all) {
|
||||
$message = "Deletion of <$color>%s</$color> in <$color>%s</$color> has <$color>%s</$color>";
|
||||
$message = sprintf($message, $cacheId, $cacheName, $success, true);
|
||||
}
|
||||
|
||||
if ($all) {
|
||||
$message = "Deletion of <$color>all</$color> entries in <$color>%s</$color> has <$color>%s</$color>";
|
||||
$message = sprintf($message, $cacheName, $success, true);
|
||||
}
|
||||
|
||||
$output->writeln($message);
|
||||
}
|
||||
}
|
||||
43
vendor/doctrine/doctrine-cache-bundle/Command/FlushCommand.php
vendored
Normal file
43
vendor/doctrine/doctrine-cache-bundle/Command/FlushCommand.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Flush a cache provider.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class FlushCommand extends CacheCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('doctrine:cache:flush')
|
||||
->setAliases(array('doctrine:cache:clear'))
|
||||
->setDescription('Flush a given cache')
|
||||
->addArgument('cache-name', InputArgument::REQUIRED, 'Which cache provider to flush?');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$cacheName = $input->getArgument('cache-name');
|
||||
$cacheProvider = $this->getCacheProvider($cacheName);
|
||||
|
||||
if ( ! method_exists($cacheProvider, 'flushAll')) {
|
||||
throw new \RuntimeException('Cache provider does not implement a flushAll method.');
|
||||
}
|
||||
|
||||
$cacheProviderName = get_class($cacheProvider);
|
||||
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> provider of type <info>%s</info>', $cacheName, $cacheProviderName, true));
|
||||
$cacheProvider->flushAll();
|
||||
}
|
||||
}
|
||||
53
vendor/doctrine/doctrine-cache-bundle/Command/StatsCommand.php
vendored
Normal file
53
vendor/doctrine/doctrine-cache-bundle/Command/StatsCommand.php
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Get stats from cache provider.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class StatsCommand extends CacheCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('doctrine:cache:stats')
|
||||
->setDescription('Get stats on a given cache provider')
|
||||
->addArgument('cache-name', InputArgument::REQUIRED, 'For which cache provider would you like to get stats?');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$cacheName = $input->getArgument('cache-name');
|
||||
$cacheProvider = $this->getCacheProvider($cacheName);
|
||||
$cacheProviderName = get_class($cacheProvider);
|
||||
|
||||
$stats = $cacheProvider->getStats();
|
||||
|
||||
if ($stats === null) {
|
||||
$output->writeln(sprintf('Stats were not provided for the <info>%s</info> provider of type <info>%s</info>', $cacheName, $cacheProviderName, true));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$formatter = $this->getHelperSet()->get('formatter');
|
||||
|
||||
$lines = array();
|
||||
foreach ($stats as $key => $stat) {
|
||||
$lines[] = $formatter->formatSection($key, $stat);
|
||||
}
|
||||
|
||||
$output->writeln(sprintf('Stats for the <info>%s</info> provider of type <info>%s</info>:', $cacheName, $cacheProviderName, true));
|
||||
$output->writeln($lines);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue