Skip to content

Commit

Permalink
remove annotation for 3.X release
Browse files Browse the repository at this point in the history
  • Loading branch information
John Quairia authored and john committed Jan 19, 2024
1 parent 0deeee9 commit 4108dc1
Show file tree
Hide file tree
Showing 30 changed files with 143 additions and 409 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ env:

on:
push:
branches:
- "*.x"
branches:
- "*.x"
pull_request:

jobs:
Expand All @@ -17,25 +17,18 @@ jobs:
matrix:
include:
# Test the latest stable release
- php-version: '7.3'
- php-version: '7.4'
- php-version: '8.0'
- php-version: '8.1'
dependencies: 'jean-beru/fos-http-cache-cloudfront'
- php-version: '7.4'
symfony-version: '4.*'
- php-version: '7.4'
symfony-version: '5.*'
- php-version: '8.0'
symfony-version: '6.*'
- php-version: '8.1'
symfony-version: '6.4'
- php-version: '8.2'
symfony-version: '7.*'
- php-version: '8.2'
symfony-version: '6.4'
# Minimum supported dependencies with the oldest PHP version
- php-version: '7.3'
- php-version: '8.1'
composer-flag: '--prefer-stable --prefer-lowest'
symfony-version: '4.4'
# Test latest unreleased versions
- php-version: '8.0'
symfony-version: '6.*'
stability: 'dev'
symfony-version: '6.4'
name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }}
steps:

Expand Down
31 changes: 15 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"friendsofsymfony/http-cache": "^2.15",
"symfony/framework-bundle": "^4.4.0 || ^5.0 || ^6.0",
"symfony/http-foundation": "^4.4.0 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4.0 || ^5.0 || ^6.0"
"php": "^8.1",
"friendsofsymfony/http-cache": "^3.x-dev",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"require-dev": {
"php-http/guzzle7-adapter": "^0.1.1",
Expand All @@ -35,20 +35,19 @@
"guzzlehttp/guzzle": "^7.2",
"mockery/mockery": "^1.3.2",
"monolog/monolog": "*",
"sensio/framework-extra-bundle": "^4.0 || ^5.5.1 || ^6.0",
"doctrine/annotations": "^1.11",
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/finder": "^6.4 || ^7.0",
"phpunit/phpunit": "^9.6.15",
"symfony/security-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
"twig/twig": "^2.13",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0",
"symfony/css-selector": "^4.4 || ^5.0 || ^6.0",
"symfony/expression-language": "^4.4 || ^5.0 || ^6.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"twig/twig": "^v3.8",
"symfony/yaml": "^6.4 || ^7.0",
"symfony/css-selector": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.0",
"symfony/routing": "^4.4 || ^5.0 || ^6.0",
"symfony/routing": "^6.4 || ^7.0",
"matthiasnoback/symfony-config-test": "^4.3.0 || ^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0"
},
Expand Down
3 changes: 0 additions & 3 deletions src/Command/BaseInvalidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use FOS\HttpCacheBundle\CacheManager;
use LogicException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand All @@ -24,8 +23,6 @@
*/
abstract class BaseInvalidateCommand extends Command
{
use ContainerAwareTrait;

/**
* @var CacheManager
*/
Expand Down
28 changes: 8 additions & 20 deletions src/Configuration/InvalidatePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

namespace FOS\HttpCacheBundle\Configuration;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class InvalidatePath extends ConfigurationAnnotation
class InvalidatePath
{
/**
* @var array
Expand All @@ -34,7 +32,13 @@ public function __construct(
$values = $data;
}

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down Expand Up @@ -62,20 +66,4 @@ public function getPaths()
{
return $this->paths;
}

/**
* {@inheritdoc}
*/
public function getAliasName(): string
{
return 'invalidate_path';
}

/**
* {@inheritdoc}
*/
public function allowArray(): bool
{
return true;
}
}
27 changes: 8 additions & 19 deletions src/Configuration/InvalidateRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

namespace FOS\HttpCacheBundle\Configuration;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class InvalidateRoute extends ConfigurationAnnotation
class InvalidateRoute
{
/**
* @var string
Expand All @@ -44,7 +43,13 @@ public function __construct(

$values['params'] = $values['params'] ?? $params;

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down Expand Up @@ -111,20 +116,4 @@ public function getParams()
{
return $this->params;
}

/**
* {@inheritdoc}
*/
public function getAliasName(): string
{
return 'invalidate_route';
}

/**
* {@inheritdoc}
*/
public function allowArray(): bool
{
return true;
}
}
27 changes: 8 additions & 19 deletions src/Configuration/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
namespace FOS\HttpCacheBundle\Configuration;

use FOS\HttpCacheBundle\Exception\InvalidTagException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Tag extends ConfigurationAnnotation
class Tag
{
private $tags;

Expand All @@ -39,7 +38,13 @@ public function __construct(

$values['expression'] = $values['expression'] ?? $expression;

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down Expand Up @@ -88,20 +93,4 @@ public function getTags()
{
return $this->tags;
}

/**
* {@inheritdoc}
*/
public function getAliasName(): string
{
return 'tag';
}

/**
* {@inheritdoc}
*/
public function allowArray(): bool
{
return true;
}
}
45 changes: 0 additions & 45 deletions src/DependencyInjection/Compiler/TagListenerPass.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/EventListener/InvalidationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private function invalidateRoutes(array $routes, Request $request)
$values['request'] = $request;

foreach ($routes as $route) {

$params = [];

if (null !== $route->getParams()) {
Expand All @@ -223,7 +224,6 @@ private function invalidateRoutes(array $routes, Request $request)
$params[$key] = $value;
}
}

$this->cacheManager->invalidateRoute($route->getName(), $params);
}
}
Expand Down
20 changes: 11 additions & 9 deletions src/EventListener/Php8AttributesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace FOS\HttpCacheBundle\EventListener;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use FOS\HttpCacheBundle\Configuration\ConfigurationInterface;
use FOS\HttpCacheBundle\Configuration\InvalidatePath;
use FOS\HttpCacheBundle\Configuration\InvalidateRoute;
use FOS\HttpCacheBundle\Configuration\Tag;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand Down Expand Up @@ -50,14 +53,13 @@ public function onKernelRequest(AttributeRequestEvent $event)
$method = $class->getMethod($controller[1]);
$attributes = [];
$addAttributes = function ($instance) use (&$attributes) {
if (
$instance instanceof ConfigurationInterface &&
in_array(
$instance->getAliasName(), [
'tag', 'invalidate_path', 'invalidate_route',
])
) {
$attributes['_'.$instance->getAliasName()][] = $instance;
if ($key = match (get_class($instance)) {
InvalidatePath::class => '_invalidate_path',
InvalidateRoute::class => '_invalidate_route',
Tag::class => '_tag'
}) {

$attributes[$key][] = $instance;
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/UserContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function isAnonymous(Request $request)
*/
public function onKernelResponse(UserContextResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST != $event->getRequestType()) {
if (HttpKernelInterface::MAIN_REQUEST != $event->getRequestType()) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions src/FOSHttpCacheBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use FOS\HttpCacheBundle\DependencyInjection\Compiler\HashGeneratorPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\LoggerPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SessionListenerPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagListenerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -27,7 +26,6 @@ class FOSHttpCacheBundle extends Bundle
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new LoggerPass());
$container->addCompilerPass(new TagListenerPass());
$container->addCompilerPass(new HashGeneratorPass());
$container->addCompilerPass(new SessionListenerPass());

Expand Down
Loading

0 comments on commit 4108dc1

Please sign in to comment.