Skip to content

Commit

Permalink
Fixed coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
excelwebzone committed Dec 11, 2020
1 parent 2e436ca commit 8133866
Show file tree
Hide file tree
Showing 20 changed files with 419 additions and 467 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class ContactFormExtension extends Extension
// ...
```
The form type class itself uses the injected service this way:
The form type class itself uses the injected service this way:
``` php
<?php
Expand All @@ -559,9 +559,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class ContactType extends AbstractType
{
/**
* @var FormBuilderInterface
*/
/** @var FormBuilderInterface */
private $recaptcha;
public function __construct(?FormBuilderInterface $recaptcha)
Expand All @@ -578,4 +576,4 @@ class ContactType extends AbstractType
// ...
}
```
```
3 changes: 2 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ private function addHttpClientConfiguration(ArrayNodeDefinition $node)
;
}

private function addServiceDefinitionConfiguration(ArrayNodeDefinition $node) {
private function addServiceDefinitionConfiguration(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('service_definition')
Expand Down
11 changes: 3 additions & 8 deletions src/DependencyInjection/EWZRecaptchaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace EWZ\Bundle\RecaptchaBundle\DependencyInjection;

use EWZ\Bundle\RecaptchaBundle\DependencyInjection\CompilerPass\WidgetCompilerPass;
use EWZ\Bundle\RecaptchaBundle\Resolver\WidgetResolver;
use EWZ\Bundle\RecaptchaBundle\Factory\EWZRecaptchaV2FormBuilderFactory;
use EWZ\Bundle\RecaptchaBundle\Factory\EWZRecaptchaV3FormBuilderFactory;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
Expand All @@ -20,7 +17,6 @@
*/
class EWZRecaptchaExtension extends Extension
{

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -51,14 +47,13 @@ public function load(array $configs, ContainerBuilder $container)
->addArgument(new Reference(FormFactoryInterface::class));
}

foreach($config['service_definition'] as $serviceDefinition) {
$container->register('ewz_recaptcha.' . $serviceDefinition['service_name'], FormBuilderInterface::class)
foreach ($config['service_definition'] as $serviceDefinition) {
$container->register('ewz_recaptcha.'.$serviceDefinition['service_name'], FormBuilderInterface::class)
->setFactory(array(
new Reference('ewz_recaptcha.form_builder_factory'),
'get'))
'get', ))
->setArguments([$serviceDefinition['options']]);
}

}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/EWZRecaptchaBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

namespace EWZ\Bundle\RecaptchaBundle;

use EWZ\Bundle\RecaptchaBundle\DependencyInjection\CompilerPass\WidgetCompilerPass;
use EWZ\Bundle\RecaptchaBundle\Resolver\WidgetResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class EWZRecaptchaBundle extends Bundle
{

}
4 changes: 1 addition & 3 deletions src/Extension/ReCaptcha/RequestMethod/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class Post implements RequestMethod
*/
private $timeout;

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

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Extension/ReCaptcha/RequestMethod/ProxyPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class ProxyPost implements RequestMethod
*/
private $timeout;

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

/**
Expand Down
54 changes: 26 additions & 28 deletions src/Factory/EWZRecaptchaV2FormBuilderFactory.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
<?php

namespace EWZ\Bundle\RecaptchaBundle\Factory;

use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue;
use Symfony\Component\Form\FormFactoryInterface;

class EWZRecaptchaV2FormBuilderFactory
{

private $builder;

public function __construct(FormFactoryInterface $builder)
{
$this->builder = $builder;
}

public function get()
{
return $this->builder->createBuilder(EWZRecaptchaType::class, null, [
'constraints' => array(
new IsTrue()
)
]);
}

}
<?php

namespace EWZ\Bundle\RecaptchaBundle\Factory;

use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue;
use Symfony\Component\Form\FormFactoryInterface;

class EWZRecaptchaV2FormBuilderFactory
{
private $builder;

public function __construct(FormFactoryInterface $builder)
{
$this->builder = $builder;
}

public function get()
{
return $this->builder->createBuilder(EWZRecaptchaType::class, null, [
'constraints' => array(
new IsTrue(),
),
]);
}
}
58 changes: 28 additions & 30 deletions src/Factory/EWZRecaptchaV3FormBuilderFactory.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<?php

namespace EWZ\Bundle\RecaptchaBundle\Factory;

use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3;
use Symfony\Component\Form\FormFactoryInterface;

class EWZRecaptchaV3FormBuilderFactory
{

private $builder;

public function __construct(FormFactoryInterface $builder)
{
$this->builder = $builder;
}

public function get(array $options = array())
{
$constraint = array(
'constraints' => array(
new IsTrueV3()
));

return $this->builder->createBuilder(EWZRecaptchaV3Type::class, null, array_merge($options, $constraint)
);
}

}
<?php

namespace EWZ\Bundle\RecaptchaBundle\Factory;

use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type;
use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3;
use Symfony\Component\Form\FormFactoryInterface;

class EWZRecaptchaV3FormBuilderFactory
{
private $builder;

public function __construct(FormFactoryInterface $builder)
{
$this->builder = $builder;
}

public function get(array $options = array())
{
$constraint = array(
'constraints' => array(
new IsTrueV3(),
), );

return $this->builder->createBuilder(EWZRecaptchaV3Type::class, null, array_merge($options, $constraint)
);
}
}
Loading

0 comments on commit 8133866

Please sign in to comment.