Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit acd35bb

Browse files
committed
Alias services with FQCNs
1 parent 4748cd7 commit acd35bb

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ Now instead of writing whole ``PersonFormType`` and populating
6565
FormBuilder there we can use instead:
6666

6767
``` php
68+
use Codete\FormGeneratorBundle\FormGenerator;
69+
70+
// Symfony 3.3+ way
71+
$generator = $this->get(FormGenerator::class);
72+
// "old way"
73+
$generator = $this->get('form_generator');
74+
6875
$person = new Person();
69-
$form = $this->get('form_generator')->createFormBuilder($person)
70-
->getForm();
76+
$form = $generator->createFormBuilder($person)->getForm();
7177
$form->handleRequest($request);
7278
```
7379

@@ -110,7 +116,7 @@ Embed Forms
110116

111117
FormGenerator will build also forms for nested models:
112118

113-
``` php
119+
``` php
114120
/*
115121
* @Form\Embed(
116122
* class = "Codete\FormGeneratorBundle\Tests\Model\Person",

Resources/config/form_generator.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<tag name="form.type" alias="embed" />
1414
<argument type="service" id="form_generator" />
1515
</service>
16+
17+
<service alias="form_generator" id="Codete\FormGeneratorBundle\FormGenerator" />
18+
19+
<service alias="form_generator.type.embed" id="Codete\FormGeneratorBundle\Form\Type\EmbedType" />
1620

1721
</services>
1822

Tests/DependencyInjection/CodeteFormGeneratorExtensionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
use Codete\FormGeneratorBundle\DependencyInjection\Compiler\ConfigurationModifiersCompilerPass;
77
use Codete\FormGeneratorBundle\DependencyInjection\Compiler\FieldResolversCompilerPass;
88
use Codete\FormGeneratorBundle\DependencyInjection\Compiler\ViewProvidersCompilerPass;
9+
use Codete\FormGeneratorBundle\Form\Type\EmbedType;
910
use Codete\FormGeneratorBundle\FormConfigurationModifierInterface;
1011
use Codete\FormGeneratorBundle\FormFieldResolverInterface;
12+
use Codete\FormGeneratorBundle\FormGenerator;
1113
use Codete\FormGeneratorBundle\FormViewProviderInterface;
1214
use Symfony\Component\DependencyInjection\ContainerBuilder;
1315

@@ -23,6 +25,9 @@ public function testCoreServicesAreLoaded()
2325
$this->assertTrue($container->has('form_generator.type.embed'));
2426
$embedType = $container->getDefinition('form_generator.type.embed');
2527
$this->assertTrue($embedType->hasTag('form.type'));
28+
29+
$this->assertTrue($container->has(FormGenerator::class));
30+
$this->assertTrue($container->has(EmbedType::class));
2631
}
2732

2833
public function testAutoconfigure()

0 commit comments

Comments
 (0)