Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Integration/Annotation/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Dispatch as DispatchAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class Dispatch
class Dispatch extends DispatchAttribute
{
public function __construct()
{
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
DispatchAttribute::class
);
}
}
47 changes: 11 additions & 36 deletions Integration/Annotation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,24 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter as FilterInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Filter as FilterAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class Filter implements Factory
class Filter extends FilterAttribute
{
protected $class;
protected $service;

public function __construct($values)
{
if (isset($values['class'])) {
$this->class = $values['class'];
}
if (isset($values['service'])) {
$this->service = $values['service'];
}
if (!$this->class && !$this->service) {
throw new \Exception('Parameter "class" or "service" is missing in Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter.');
}
}

public function createFilter(ContainerInterface $container)
{
if ($class = $this->class) {
if (!class_exists($class)) {
throw new \Exception('Unknown class '.$class.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
}
$filter = new $class();
}
if ($service = $this->service) {
if (!$container->has($service)) {
throw new \Exception('Unknown service '.$service.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
}
$filter = $container->get($service);
}
if (!$filter instanceof FilterInterface) {
throw new \Exception('Class '.\get_class($filter).' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation is not a Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter.');
}
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
FilterAttribute::class
);

return $filter;
parent::__construct($values);
}
}
25 changes: 11 additions & 14 deletions Integration/Annotation/IgnoreHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\IgnoreHeader as IgnoreHeaderFilter;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\IgnoreHeader as IgnoreHeaderAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class IgnoreHeader implements Factory
class IgnoreHeader extends IgnoreHeaderAttribute
{
protected $header;

public function __construct(array $values)
{
$this->header = array_shift($values);
if (!\is_string($this->header)) {
throw new \Exception("Please define a header with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\IgnoreHeader annotation.");
}
}
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
IgnoreHeaderAttribute::class
);

public function createFilter(ContainerInterface $container)
{
return new IgnoreHeaderFilter($this->header);
parent::__construct($values);
}
}
17 changes: 11 additions & 6 deletions Integration/Annotation/IgnoreRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\IgnoreRedirect as IgnoreRedirectFilter;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\IgnoreRedirect as IgnoreRedirectAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class IgnoreRedirect implements Factory
class IgnoreRedirect extends IgnoreRedirectAttribute
{
public function createFilter(ContainerInterface $container)
public function __construct()
{
return new IgnoreRedirectFilter();
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
IgnoreRedirectAttribute::class
);
}
}
17 changes: 12 additions & 5 deletions Integration/Annotation/KeepCookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepCookies as KeepCookiesAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class KeepCookies
class KeepCookies extends KeepCookiesAttribute
{
public $value;

public function shouldKeep($name)
public function __construct()
{
return null === $this->value || \in_array($name, $this->value);
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
KeepCookiesAttribute::class
);
}
}
17 changes: 12 additions & 5 deletions Integration/Annotation/KeepHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepHeaders as KeepHeadersAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class KeepHeaders
class KeepHeaders extends KeepHeadersAttribute
{
public $value;

public function shouldKeep($name)
public function __construct()
{
return null === $this->value || \in_array($name, $this->value);
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
KeepHeadersAttribute::class
);
}
}
17 changes: 11 additions & 6 deletions Integration/Annotation/Passthru.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\PassthruLegacyResponseFilter;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Passthru as PassthruAttribute;

/**
* @Annotation
* @deprecated Use the attribute instead.
*/
class Passthru implements Factory
class Passthru extends PassthruAttribute
{
public function createFilter(ContainerInterface $container)
public function __construct()
{
return new PassthruLegacyResponseFilter();
trigger_deprecation(
'webfactory/legacy-integration-bundle',
'2.4.0',
'The %s annotation has been deprecated, use the %s attribute instead.',
__CLASS__,
PassthruAttribute::class
);
}
}
16 changes: 16 additions & 0 deletions Integration/Attribute/Dispatch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/*
* (c) webfactory GmbH <info@webfactory.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute;

use Attribute;

#[Attribute(Attribute::TARGET_METHOD)]
class Dispatch
{
}
59 changes: 59 additions & 0 deletions Integration/Attribute/Filter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/*
* (c) webfactory GmbH <info@webfactory.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute;

use Attribute;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter as FilterInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;

#[Attribute(Attribute::TARGET_METHOD)]
class Filter implements Factory
{
protected $class;
protected $service;

public function __construct($values)
{
if (isset($values['class'])) {
$this->class = $values['class'];
}

if (isset($values['service'])) {
$this->service = $values['service'];
}

if (!$this->class && !$this->service) {
throw new \Exception('Parameter "class" or "service" is missing in Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter.');
}
}

public function createFilter(ContainerInterface $container)
{
if ($class = $this->class) {
if (!class_exists($class)) {
throw new \Exception('Unknown class '.$class.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
}
$filter = new $class();
}

if ($service = $this->service) {
if (!$container->has($service)) {
throw new \Exception('Unknown service '.$service.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
}
$filter = $container->get($service);
}

if (!$filter instanceof FilterInterface) {
throw new \Exception('Class '.\get_class($filter).' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation is not a Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter.');
}

return $filter;
}
}
33 changes: 33 additions & 0 deletions Integration/Attribute/IgnoreHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
* (c) webfactory GmbH <info@webfactory.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute;

use Attribute;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\IgnoreHeader as IgnoreHeaderFilter;

#[Attribute(Attribute::TARGET_METHOD)]
class IgnoreHeader implements Factory
{
protected $header;

public function __construct(array $values)
{
$this->header = array_shift($values);
if (!\is_string($this->header)) {
throw new \Exception("Please define a header with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\IgnoreHeader annotation.");
}
}

public function createFilter(ContainerInterface $container)
{
return new IgnoreHeaderFilter($this->header);
}
}
23 changes: 23 additions & 0 deletions Integration/Attribute/IgnoreRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/*
* (c) webfactory GmbH <info@webfactory.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute;

use Attribute;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\Factory;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter\IgnoreRedirect as IgnoreRedirectFilter;

#[Attribute(Attribute::TARGET_METHOD)]
class IgnoreRedirect implements Factory
{
public function createFilter(ContainerInterface $container)
{
return new IgnoreRedirectFilter();
}
}
22 changes: 22 additions & 0 deletions Integration/Attribute/KeepCookies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/*
* (c) webfactory GmbH <info@webfactory.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute;

use Attribute;

#[Attribute(Attribute::TARGET_METHOD)]
class KeepCookies
{
public $value;

public function shouldKeep($name)
{
return null === $this->value || \in_array($name, $this->value);
}
}
Loading