Skip to content
This repository was archived by the owner on May 2, 2020. It is now read-only.

Commit 2571d34

Browse files
committed
Merge pull request #62 from rvanlaarhoven/cleanup
Cleanup & Symfony 3.0 preparations
2 parents 2ec424f + 4388e99 commit 2571d34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+221
-430
lines changed

Controller/FormController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Opifer\EavBundle\Controller;
44

5+
use Opifer\EavBundle\Form\Type\NestedType;
6+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
58
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
69
use Symfony\Component\HttpFoundation\JsonResponse;
10+
use Symfony\Component\HttpFoundation\RedirectResponse;
711
use Symfony\Component\HttpFoundation\Request;
812
use Symfony\Component\HttpFoundation\Response;
9-
use Symfony\Component\HttpFoundation\RedirectResponse;
1013
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
11-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
12-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
13-
use Opifer\EavBundle\Form\Type\NestedType;
1414

1515
class FormController extends Controller
1616
{

DependencyInjection/Compiler/ValueCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Opifer\EavBundle\DependencyInjection\Compiler;
44

5-
use Symfony\Component\DependencyInjection\ContainerBuilder;
65
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Reference;
88

99
class ValueCompilerPass implements CompilerPassInterface

DependencyInjection/OpiferEavExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Opifer\EavBundle\DependencyInjection;
44

5-
use Symfony\Component\DependencyInjection\ContainerBuilder;
65
use Symfony\Component\Config\FileLocator;
7-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
87
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
98
use Symfony\Component\DependencyInjection\Loader;
9+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1010

1111
/**
1212
* This is the class that loads and manages your bundle configuration

Entity/NestedValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Opifer\EavBundle\Entity;
44

5-
use Doctrine\ORM\Mapping as ORM;
65
use Doctrine\Common\Collections\ArrayCollection;
6+
use Doctrine\ORM\Mapping as ORM;
77
use Opifer\EavBundle\Model\Nestable;
88

99
/**

Entity/TwitterValue.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

Entity/Value.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use Doctrine\ORM\Mapping as ORM;
77
use JMS\Serializer\Annotation as JMS;
88
use Opifer\EavBundle\Model\AttributeInterface;
9+
use Opifer\EavBundle\Model\OptionInterface;
910
use Opifer\EavBundle\Model\ValueInterface;
1011
use Opifer\EavBundle\Model\ValueSetInterface;
11-
use Opifer\EavBundle\Model\OptionInterface;
1212

1313
/**
1414
* Value

EventListener/EmptyValueListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Opifer\EavBundle\EventListener;
44

55
use Doctrine\ORM\Event\LifecycleEventArgs;
6+
use Opifer\EavBundle\Manager\EavManager;
67
use Opifer\EavBundle\Model\ValueInterface;
78
use Opifer\EavBundle\Model\ValueSetInterface;
8-
use Opifer\EavBundle\Manager\EavManager;
99

1010
/**
1111
* Empty Value Listener

Form/Type/AttributeType.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,32 @@
22

33
namespace Opifer\EavBundle\Form\Type;
44

5+
use Doctrine\ORM\EntityRepository;
56
use Symfony\Component\Form\AbstractType;
7+
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
8+
use Symfony\Component\Form\Extension\Core\Type\TextType;
69
use Symfony\Component\Form\FormBuilderInterface;
7-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
810
use Symfony\Component\Form\FormEvent;
911
use Symfony\Component\Form\FormEvents;
10-
use Doctrine\ORM\EntityRepository;
12+
use Symfony\Component\OptionsResolver\OptionsResolver;
1113

1214
class AttributeType extends AbstractType
1315
{
14-
/**
15-
* @var string
16-
*/
16+
/** @var string */
1717
protected $attributeClass;
1818

19-
/**
20-
* @var string
21-
*/
19+
/** @var string */
2220
protected $templateClass;
2321

22+
/** @var OptionType */
2423
protected $optionType;
2524

26-
2725
/**
2826
* Constructor
2927
*
30-
* @param OptionType $optionType
31-
* @param string $attributeClass
32-
* @param string $templateClass
28+
* @param OptionType $optionType
29+
* @param string $attributeClass
30+
* @param string $templateClass
3331
*/
3432
public function __construct(OptionType $optionType, $attributeClass, $templateClass)
3533
{
@@ -50,7 +48,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5048
'placeholder' => 'form.value_type.placeholder',
5149
'help_text' => 'form.value_type.help_text'
5250
]
53-
])->add('displayName', 'text', [
51+
])->add('displayName', TextType::class, [
5452
'label' => 'attribute.display_name',
5553
'attr' => [
5654
'class' => 'slugify',
@@ -60,19 +58,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6058
'help_text' => 'form.display_name.help_text',
6159
'widget_col' => 6
6260
]
63-
])->add('name', 'text', [
61+
])->add('name', TextType::class, [
6462
'label' => 'attribute.name',
6563
'attr' => [
6664
'class' => 'slugify-target-' . $builder->getName(),
6765
'placeholder' => 'form.name.placeholder',
6866
'help_text' => 'form.name.help_text',
6967
'widget_col' => 6
7068
]
71-
])->add('description', 'text', [
69+
])->add('description', TextType::class, [
7270
'required' => false,
7371
'label' => 'attribute.description',
7472
'attr' => [ 'help_text' => 'form.description.help_text' ]
75-
])->add('sort', 'integer', [
73+
])->add('sort', IntegerType::class, [
7674
'label' => 'attribute.sort',
7775
'attr' => [ 'help_text' => 'form.sort.help_text', 'widget_col' => 2 ],
7876
'empty_data' => 0
@@ -91,44 +89,46 @@ public function buildForm(FormBuilderInterface $builder, array $options)
9189
}
9290

9391
if ($attribute && $attribute->getValueType() == 'nested') {
94-
$form->add(
95-
'allowedTemplates',
96-
'entity',
97-
[
98-
'class' => $this->templateClass,
99-
'property' => 'displayName',
100-
'query_builder' => function (EntityRepository $er) {
101-
return $er->createQueryBuilder('t')
102-
->orderBy('t.displayName', 'ASC');
103-
},
104-
'by_reference' => false,
105-
'expanded' => true,
106-
'multiple' => true,
107-
'label' => 'attribute.allowed_templates',
108-
'attr' => ['help_text' => 'form.allowed_templates.help_text']
109-
]
110-
);
92+
$form->add('allowedTemplates', 'entity', [
93+
'class' => $this->templateClass,
94+
'property' => 'displayName',
95+
'query_builder' => function (EntityRepository $er) {
96+
return $er->createQueryBuilder('t')
97+
->orderBy('t.displayName', 'ASC');
98+
},
99+
'by_reference' => false,
100+
'expanded' => true,
101+
'multiple' => true,
102+
'label' => 'attribute.allowed_templates',
103+
'attr' => ['help_text' => 'form.allowed_templates.help_text']
104+
]);
111105
}
112106
});
113107
}
114108

115-
116109
/**
117110
* {@inheritDoc}
118111
*/
119-
public function setDefaultOptions(OptionsResolverInterface $resolver)
112+
public function configureOptions(OptionsResolver $resolver)
120113
{
121-
$resolver->setDefaults(array(
114+
$resolver->setDefaults([
122115
'data_class' => $this->attributeClass,
123-
));
116+
]);
124117
}
125118

119+
/**
120+
* @deprecated
121+
*/
122+
public function getName()
123+
{
124+
return $this->getBlockPrefix();
125+
}
126126

127127
/**
128128
* {@inheritDoc}
129129
*/
130-
public function getName()
130+
public function getBlockPrefix()
131131
{
132132
return 'eav_attribute';
133133
}
134-
}
134+
}

Form/Type/DatePickerType.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ public function getParent()
2828
}
2929

3030
/**
31-
* {@inheritDoc}
31+
* @deprecated
3232
*/
3333
public function getName()
34+
{
35+
return $this->getBlockPrefix();
36+
}
37+
38+
/**
39+
* {@inheritDoc}
40+
*/
41+
public function getBlockPrefix()
3442
{
3543
return 'opifer_eav_date_picker';
3644
}

Form/Type/DateTimePickerType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Opifer\EavBundle\Form\Type;
44

55
use Symfony\Component\Form\AbstractType;
6+
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
67
use Symfony\Component\OptionsResolver\OptionsResolver;
78

89
class DateTimePickerType extends AbstractType
@@ -34,4 +35,12 @@ public function getName()
3435
{
3536
return 'opifer_eav_datetime_picker';
3637
}
38+
39+
/**
40+
* {@inheritDoc}
41+
*/
42+
public function getBlockPrefix()
43+
{
44+
return 'opifer_eav_datetime_picker';
45+
}
3746
}

0 commit comments

Comments
 (0)