diff --git a/README.md b/README.md index ac2dd91..dbfc231 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ This bundle supports the following Oro Platform versions: * Oro Platform v5.x - Support for this version is on the "v5.x" branch +* Oro Platform v6.0.x + - Support for this version is on the "v6.0.x" branch + The Master branch will always track support for the latest released Oro Platform version. Installation and Usage diff --git a/composer.json b/composer.json index d814226..36fb549 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Oro Bundle to inject ReCAPTCHA into public forms", "type": "project", "require": { - "oro/platform": "5.1.*", + "oro/platform": "6.0.*", "excelwebzone/recaptcha-bundle": "^1.5" }, "autoload": { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e874257..5487644 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -25,10 +25,8 @@ class Configuration implements ConfigurationInterface /** * Generates the configuration tree builder. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(HackOroRecaptchaExtension::ALIAS); $rootNode = $treeBuilder->getRootNode(); @@ -41,20 +39,19 @@ public function getConfigTreeBuilder() self::THEME => ['type' => 'scalar', 'value' => 'light'], // light/dark (default light) self::SIZE => ['type' => 'scalar', 'value' => 'normal'], // normal/compact (default normal) self::PROTECT_REGISTRATION => ['type' => 'boolean', 'value' => true], - self::PROTECT_CONTACT_FORM=> ['type' => 'boolean', 'value' => true], + self::PROTECT_CONTACT_FORM => ['type' => 'boolean', 'value' => true], ] ); return $treeBuilder; } - - /** - * Returns full key name by it's last part - * - * @param $name string last part of the key name (one of the class cons can be used) - * @return string full config path key - */ - public static function getConfigKeyByName($name) + /** + * Returns full key name by it's last part + * + * @param $name string last part of the key name (one of the class cons can be used) + * @return string full config path key + */ + public static function getConfigKeyByName(string $name): string { return HackOroRecaptchaExtension::ALIAS . ConfigManager::SECTION_MODEL_SEPARATOR . $name; } diff --git a/src/DependencyInjection/HackOroRecaptchaExtension.php b/src/DependencyInjection/HackOroRecaptchaExtension.php index 2550b84..0dc748e 100644 --- a/src/DependencyInjection/HackOroRecaptchaExtension.php +++ b/src/DependencyInjection/HackOroRecaptchaExtension.php @@ -21,7 +21,7 @@ class HackOroRecaptchaExtension extends Extension /** * @inheritdoc */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); diff --git a/src/Form/Extension/AbstractRecaptchaTypeExtension.php b/src/Form/Extension/AbstractRecaptchaTypeExtension.php index 310c6db..e493a72 100644 --- a/src/Form/Extension/AbstractRecaptchaTypeExtension.php +++ b/src/Form/Extension/AbstractRecaptchaTypeExtension.php @@ -21,13 +21,11 @@ abstract class AbstractRecaptchaTypeExtension extends AbstractTypeExtension const DEFAULT_THEME = 'light'; const DEFAULT_SIZE = 'normal'; - /** @var ConfigManager */ - protected $configManager; + protected ConfigManager $configManager; - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { if ($this->isProtected()) { - $builder->add('recaptcha', EWZRecaptchaType::class, [ 'attr' => [ 'options' => [ @@ -44,44 +42,28 @@ public function buildForm(FormBuilderInterface $builder, array $options) } } - /** - * @param ConfigManager $configManager - */ - public function setConfigManager(ConfigManager $configManager) + public function setConfigManager(ConfigManager $configManager): void { $this->configManager = $configManager; } - /** - * @return mixed - */ - protected function getTheme() + protected function getTheme(): mixed { return $this->getConfiguration(Configuration::THEME, self::DEFAULT_THEME); } - /** - * @return mixed - */ - protected function getSize() + protected function getSize(): mixed { return $this->getConfiguration(Configuration::SIZE, self::DEFAULT_SIZE); } /** * Get configuration option - * @param string $key - * @param $default - * @return mixed */ - protected function getConfiguration(string $key, $default = null) + protected function getConfiguration(string $key, mixed $default = null): mixed { return $this->configManager->get(Configuration::getConfigKeyByName($key)) ?? $default; } - /** - * @return boolean - */ - abstract public function isProtected(); - -} \ No newline at end of file + abstract public function isProtected(): bool; +} diff --git a/src/Form/Extension/ContactUsTypeExtension.php b/src/Form/Extension/ContactUsTypeExtension.php index 95c16e3..46e4722 100644 --- a/src/Form/Extension/ContactUsTypeExtension.php +++ b/src/Form/Extension/ContactUsTypeExtension.php @@ -14,16 +14,15 @@ class ContactUsTypeExtension extends AbstractRecaptchaTypeExtension { - public function getExtendedType() + public function getExtendedType(): string { return ContactRequestType::class; } /** * Protect the Contact Us Form? - * @return boolean */ - public function isProtected() + public function isProtected(): bool { return $this->getConfiguration(Configuration::PROTECT_CONTACT_FORM, false); } diff --git a/src/Form/Extension/RegistrationTypeExtension.php b/src/Form/Extension/RegistrationTypeExtension.php index ae40bbd..0869ca2 100644 --- a/src/Form/Extension/RegistrationTypeExtension.php +++ b/src/Form/Extension/RegistrationTypeExtension.php @@ -14,16 +14,15 @@ class RegistrationTypeExtension extends AbstractRecaptchaTypeExtension { - public function getExtendedType() + public function getExtendedType(): string { return FrontendCustomerUserRegistrationType::class; } /** * Protect the Registration Form? - * @return boolean */ - public function isProtected() + public function isProtected(): bool { return $this->getConfiguration(Configuration::PROTECT_REGISTRATION, false); } @@ -35,5 +34,4 @@ public static function getExtendedTypes(): iterable { return [FrontendCustomerUserRegistrationType::class]; } - }