From f0c10fbe5cad48f091c1ec9b7e01fc0c25f40f6d Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Mon, 26 Jun 2023 12:02:20 +0300 Subject: [PATCH] Provide backwards compatibility for old event classes --- src/Event/AfterTableFetchEvent.php | 80 +++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/src/Event/AfterTableFetchEvent.php b/src/Event/AfterTableFetchEvent.php index 6c53a95..7115445 100644 --- a/src/Event/AfterTableFetchEvent.php +++ b/src/Event/AfterTableFetchEvent.php @@ -5,36 +5,70 @@ namespace LoversOfBehat\TableExtension\Event; use LoversOfBehat\TableExtension\HtmlContainer; -use Symfony\Component\EventDispatcher\Event; - -/** - * Event that fires after fetching a table from the web page. - */ -class AfterTableFetchEvent extends Event implements TableEventInterface -{ - - /** - * An object containing the HTML of the fetched table. - * - * @var HtmlContainer - */ - protected $htmlContainer; +if (class_exists('Symfony\Component\EventDispatcher\Event')) { /** - * Constructs a new AfterTableFetchEvent object. - * - * @param HtmlContainer $htmlContainer + * Event that fires after fetching a table from the web page. */ - public function __construct(HtmlContainer $htmlContainer) + class AfterTableFetchEvent extends Symfony\Component\EventDispatcher\Event implements TableEventInterface { - $this->htmlContainer = $htmlContainer; - } + /** + * An object containing the HTML of the fetched table. + * + * @var HtmlContainer + */ + protected $htmlContainer; + + /** + * Constructs a new AfterTableFetchEvent object. + * + * @param HtmlContainer $htmlContainer + */ + public function __construct(HtmlContainer $htmlContainer) + { + $this->htmlContainer = $htmlContainer; + } + + /** + * {@inheritdoc} + */ + public function getHtmlContainer(): HtmlContainer + { + return $this->htmlContainer; + } + } +} +else { /** - * {@inheritdoc} + * Event that fires after fetching a table from the web page. */ - public function getHtmlContainer(): HtmlContainer + class AfterTableFetchEvent extends \Symfony\Contracts\EventDispatcher\Event implements TableEventInterface { - return $this->htmlContainer; + + /** + * An object containing the HTML of the fetched table. + * + * @var HtmlContainer + */ + protected $htmlContainer; + + /** + * Constructs a new AfterTableFetchEvent object. + * + * @param HtmlContainer $htmlContainer + */ + public function __construct(HtmlContainer $htmlContainer) + { + $this->htmlContainer = $htmlContainer; + } + + /** + * {@inheritdoc} + */ + public function getHtmlContainer(): HtmlContainer + { + return $this->htmlContainer; + } } }