Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add coke to require dev and travis, update style to please coke.
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-claras committed Feb 10, 2016
1 parent 4eb92e3 commit 1911490
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .coke
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
standard=Cytron
standard=vendor/m6web/symfony2-coding-standard/M6Web_Symfony2

src/
!Tests/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ before_script:

script:
- bin/atoum
- bin/coke
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"require-dev": {
"symfony/symfony": "~2.3|~3.0",
"m6web/firewall-bundle": "~1.0",
"atoum/atoum": "~2.0"
"atoum/atoum": "~2.0",
"m6web/coke": "~2.1",
"m6web/symfony2-coding-standard": "~3.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/DataCollector/CacheActionDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function collect(Request $request, Response $response, \Exception $except
'blocks' => $blocks,
'total' => $total,
'hits' => $nbHits,
'miss' => $nbMiss
'miss' => $nbMiss,
];
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/Bundle/DependencyInjection/M6WebCacheExtraExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class M6WebCacheExtraExtension extends Extension
{
protected $twigExtension = array('renderCache');

/**
* @return string
*/
public function getAlias()
{
return 'm6_cache_extra';
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -45,6 +53,7 @@ public function load(array $configs, ContainerBuilder $container)
}
}


/**
* Load the cache action configuration
*
Expand All @@ -70,13 +79,4 @@ protected function loadActionCacheConfiguration(ContainerBuilder $container, $ca
$definition->addTag('kernel.event_subscriber');
$container->setDefinition('m6.action_cache.listener', $definition);
}


/**
* @return string
*/
public function getAlias()
{
return 'm6_cache_extra';
}
}
16 changes: 8 additions & 8 deletions src/Bundle/Fragment/CachedFragmentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
*/
class CachedFragmentRenderer extends InlineFragmentRenderer
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'cached';
}

/**
* {@inheritdoc}
*/
Expand All @@ -30,12 +38,4 @@ protected function createSubRequest($uri, Request $request)

return $subRequest;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'cached';
}
}
50 changes: 25 additions & 25 deletions src/Bundle/Listener/CacheActionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@ public function setCacheKeyExclude(array $exclude)
$this->excludeKey = $exclude;
}

/**
* Return list of cached blocks with status
*
* @return array list of cached controller with status
*/
public function getCachedBlocks()
{
return $this->cachedBlocks;
}

/**
* Return static list of subscribed events
*
* @return array List of events we want to subscribe to
*/
public static function getSubscribedEvents()
{
return [
KernelEvents::RESPONSE => 'onKernelResponse',
KernelEvents::REQUEST => 'onKernelRequest',
];
}

/**
* Method called on kernel.request event. Handle only "subrequest"
* @param KernelEvent $event The received event
Expand All @@ -81,7 +104,7 @@ public function onKernelRequest(KernelEvent $event)
$fromCache = false;

$responseContent = $this->cacheService->getConcurrent($cacheKey);
if ($responseContent || ($responseContent === '' && !$request->attributes->get('ignore_errors')) ) {
if ($responseContent || ($responseContent === '' && !$request->attributes->get('ignore_errors'))) {

$response = new Response($responseContent);
$response->headers->set('server_cached', 1);
Expand Down Expand Up @@ -136,7 +159,7 @@ public function onKernelResponse(FilterResponseEvent $event)
private function getRequestCacheKey(Request $request)
{
$p = $request->attributes->all();
$parameters = array();
$parameters = [];
foreach ($p as $k => $v) {

// On ne prend pas ces clefs
Expand Down Expand Up @@ -221,27 +244,4 @@ private function decorateResponse(Request $request, Response $response, $control

$response->setContent($html);
}

/**
* Return static list of subscribed events
*
* @return array List of events we want to subscribe to
*/
public static function getSubscribedEvents()
{
return array(
KernelEvents::RESPONSE => 'onKernelResponse',
KernelEvents::REQUEST => 'onKernelRequest'
);
}

/**
* Return list of cached blocks with status
*
* @return array list of cached controller with status
*/
public function getCachedBlocks()
{
return $this->cachedBlocks;
}
}
28 changes: 14 additions & 14 deletions src/Bundle/Listener/VarnishPurgeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ public function __construct(CacheResetterInterface $cacheResetter, $purgeHelper
$this->cacheResetter = $cacheResetter;
}

/**
* Return static list of subscribed events
*
* @return array List of events we want to subscribe to
*/
public static function getSubscribedEvents()
{
return [
'kernel.request' => [
['onKernelRequest', 0],
],
];
}

/**
* Purge varnish servers when a kernel.request event is dispatched
*
Expand Down Expand Up @@ -109,18 +123,4 @@ protected function cleanUrl($url)

return $url;
}

/**
* Return static list of subscribed events
*
* @return array List of events we want to subscribe to
*/
public static function getSubscribedEvents()
{
return [
'kernel.request' => [
['onKernelRequest', 0],
],
];
}
}
3 changes: 3 additions & 0 deletions src/Bundle/M6WebCacheExtraBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
class M6WebCacheExtraBundle extends Bundle
{
/**
* @return DependencyInjection\M6WebCacheExtraExtension
*/
public function getContainerExtension()
{
return new DependencyInjection\M6WebCacheExtraExtension();
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/Resetter/CacheResetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CacheResetter implements CacheResetterInterface

/**
* Construct the cache resetter
*
*
* @param EventDispatcherInterface $eventDispatcher The Event Dispatcher to dispatch the cache.reset event
* @param string $paramName Name of the parameter to check to purge
* @param Provider $firewallProvider Firewall provider (Factory)
Expand Down Expand Up @@ -69,7 +69,7 @@ public function getAllowedIps()

/**
* Set the request object
*
*
* @param Request $request The Request object
*
* @return $this
Expand Down

0 comments on commit 1911490

Please sign in to comment.