Skip to content

Commit

Permalink
Drop symfony 3.4 support (#275)
Browse files Browse the repository at this point in the history
* Removed Symfony 3.4 from composer allowed dependencies

* Removed conditional event contract existence from code base

* Removed conditional configuration init due to Symfony 3.4

* Updated testing matrix versions
  • Loading branch information
yann-eugone authored Mar 26, 2021
1 parent 94ed43e commit 51fd0c0
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 344 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ jobs:
strategy:
matrix:
include:
- php-version: 7.1
symfony-version: 3.4.*
- php-version: 7.4
symfony-version: 3.4.*
- php-version: 7.1
symfony-version: 4.4.*
- php-version: 7.4
symfony-version: 4.4.*
- php-version: 7.2
symfony-version: 5.1.*
symfony-version: 5.2.*
- php-version: 7.4
symfony-version: 5.1.*
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand All @@ -37,14 +33,14 @@ jobs:
coverage: none
php-version: ${{ matrix.php-version }}

- name: "Require symfony/messenger dependencies when possible"
if: matrix.symfony-version != '3.4.*'
run: |
composer require --no-update symfony/messenger:${{ matrix.symfony-version }}
- name: "Install dependencies with composer"
run: |
composer require symfony/console:${{ matrix.symfony-version }} symfony/framework-bundle:${{ matrix.symfony-version }} symfony/http-kernel:${{ matrix.symfony-version }} symfony/routing:${{ matrix.symfony-version }} --no-interaction --no-update
composer require --no-interaction --no-update \
symfony/console:${{ matrix.symfony-version }} \
symfony/framework-bundle:${{ matrix.symfony-version }} \
symfony/http-kernel:${{ matrix.symfony-version }} \
symfony/routing:${{ matrix.symfony-version }} \
symfony/messenger:${{ matrix.symfony-version }}
composer update --no-interaction --no-progress --no-suggest
- name: "Run tests with phpunit/phpunit"
Expand All @@ -58,7 +54,7 @@ jobs:
matrix:
include:
- php-version: 7.4
symfony-version: 5.1.*
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand Down
9 changes: 2 additions & 7 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('presta_sitemap');
$rootNode = $treeBuilder->getRootNode();
} else {
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('presta_sitemap');
}
$treeBuilder = new TreeBuilder('presta_sitemap');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
294 changes: 94 additions & 200 deletions Event/SitemapAddUrlEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,213 +12,107 @@
namespace Presta\SitemapBundle\Event;

use Presta\SitemapBundle\Sitemap\Url\Url;
use Symfony\Component\EventDispatcher\Event as BaseEvent;
use Symfony\Contracts\EventDispatcher\Event as ContractsBaseEvent;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Event to allow generation of static routes sitemap urls.
*/
class SitemapAddUrlEvent extends Event
{
/**
* @Event("Presta\SitemapBundle\Event\SitemapAddUrlEvent")
*/
public const NAME = 'presta_sitemap.add_url';

/**
* @var bool
*/
private $shouldBeRegistered = true;

/**
* @var Url|null
*/
private $url;

/**
* @var string
*/
private $route;

/**
* @var array
*/
private $options;

public function __construct(string $route, array $options)
{
$this->route = $route;
$this->options = $options;
}

/**
* Whether or not associated URL should be registered to sitemap.
*
* @return bool
*/
public function shouldBeRegistered(): bool
{
return $this->shouldBeRegistered;
}

/**
* Allow URL registration to sitemap.
*/
public function allowRegistration(): void
{
$this->shouldBeRegistered = true;
}

/**
* Prevent URL registration to sitemap.
*/
public function preventRegistration(): void
{
$this->shouldBeRegistered = false;
}

if (is_subclass_of('Symfony\Component\EventDispatcher\EventDispatcher', 'Symfony\Contracts\EventDispatcher\EventDispatcherInterface')) {
/**
* Event to allow generation of static routes sitemap urls.
* URL that is about to be added to sitemap or NULL if not set yet.
*
* @return Url|null
*/
class SitemapAddUrlEvent extends ContractsBaseEvent
public function getUrl(): ?Url
{
/**
* @Event("Presta\SitemapBundle\Event\SitemapAddUrlEvent")
*/
public const NAME = 'presta_sitemap.add_url';

/**
* @var bool
*/
private $shouldBeRegistered = true;

/**
* @var Url|null
*/
private $url;

/**
* @var string
*/
private $route;

/**
* @var array
*/
private $options;

public function __construct(string $route, array $options)
{
$this->route = $route;
$this->options = $options;
}

/**
* Whether or not associated URL should be registered to sitemap.
*
* @return bool
*/
public function shouldBeRegistered(): bool
{
return $this->shouldBeRegistered;
}

/**
* Allow URL registration to sitemap.
*/
public function allowRegistration(): void
{
$this->shouldBeRegistered = true;
}

/**
* Prevent URL registration to sitemap.
*/
public function preventRegistration(): void
{
$this->shouldBeRegistered = false;
}

/**
* URL that is about to be added to sitemap or NULL if not set yet.
*
* @return Url|null
*/
public function getUrl(): ?Url
{
return $this->url;
}

/**
* Set the URL that will be added to sitemap.
*
* @param Url $url Replacement
*/
public function setUrl(Url $url): void
{
$this->url = $url;
}

/**
* The route name.
*
* @return string
*/
public function getRoute(): string
{
return $this->route;
}

/**
* The sitemap route options.
*
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
return $this->url;
}
} else {

/**
* Set the URL that will be added to sitemap.
*
* @param Url $url Replacement
*/
public function setUrl(Url $url): void
{
$this->url = $url;
}

/**
* The route name.
*
* @return string
*/
public function getRoute(): string
{
return $this->route;
}

/**
* Event to allow generation of static routes sitemap urls.
* The sitemap route options.
*
* @return array
*/
class SitemapAddUrlEvent extends BaseEvent
public function getOptions(): array
{
/**
* @Event("Presta\SitemapBundle\Event\SitemapAddUrlEvent")
*/
public const NAME = 'presta_sitemap.add_url';

/**
* @var bool
*/
private $shouldBeRegistered = true;

/**
* @var Url|null
*/
private $url;

/**
* @var string
*/
private $route;

/**
* @var array
*/
private $options;

public function __construct(string $route, array $options)
{
$this->route = $route;
$this->options = $options;
}

/**
* Whether or not associated URL should be registered to sitemap.
*
* @return bool
*/
public function shouldBeRegistered(): bool
{
return $this->shouldBeRegistered;
}

/**
* Allow URL registration to sitemap.
*/
public function allowRegistration(): void
{
$this->shouldBeRegistered = true;
}

/**
* Prevent URL registration to sitemap.
*/
public function preventRegistration(): void
{
$this->shouldBeRegistered = false;
}

/**
* URL that is about to be added to sitemap or NULL if not set yet.
*
* @return Url|null
*/
public function getUrl(): ?Url
{
return $this->url;
}

/**
* Set the URL that will be added to sitemap.
*
* @param Url $url Replacement
*/
public function setUrl(Url $url): void
{
$this->url = $url;
}

/**
* The route name.
*
* @return string
*/
public function getRoute(): string
{
return $this->route;
}

/**
* The sitemap route options.
*
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
return $this->options;
}
}
Loading

0 comments on commit 51fd0c0

Please sign in to comment.