Message-ID: <2037407348.3768.1485855268735.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3767_1365283579.1485855268735" ------=_Part_3767_1365283579.1485855268735 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Create the bundle

Create the bundle

=20
=20
=20
=20

Custom Field Types follow the Symfony 2 extension mechanism: bundles. We can get started with a bundle us= ing the built-in Symfony 2 bundle generator.

Generating the bundle

From the eZ Platform root, run the following:

=20
php app/console generate:bundle
=20

First, we are asked for the namespace. As the vendor, we will use EzSyst= ems as the root namespace. This must of course be changed to whatever ident= ifies you as a vendor (your name, company name, etc). We then choose a pref= erably unique name for the Field Type itself, and make the name end with Bu= ndle. Here we=E2=80=99ve chosen TweetFieldTypeBundle.

 

=20
Bundle namespace: EzSystems/TweetFieldTypeBundle<enter>
=20

We must next input the bundle=E2=80=99s name. Nothing exotic here: we co= ncatenate the vendor=E2=80=99s namespace and the bundle=E2=80=99s namespace= , which is the default. Just hit Enter:

=20
Bundle name [EzSystemsTweetFieldTypeBundle]:<enter>
=20

We are then asked for the target directory. We will begin within the src folder, but we could (and should!) version it and have it mov= ed to vendor at some point. Again, this is the default, and we= just hit Enter.

=20
Target directory [/home/bertrand/www/ezpublish5/src]:<enter>=
=20

We must then specify which format the configuration must be generated as= . We will use yml, since it is what we use in eZ Platform itself. Of course= , any other format could be used.

=20
Configuration format (yml, xml, php, or annotation): yml<enter&=
gt;
=20

The generator will then offer to create the whole directory structure fo= r us. Since our bundle isn=E2=80=99t really a standard Symfony full stack b= undle, we decline.

=20
Do you want to generate the whole directory structure [no]? no<=
enter>
=20

 

We then get a summary of what will be generated:

=20
You are going to generate a "EzSystems\TweetFieldTypeBundle\EzSyst=
emsTweetFieldTypeBundle" bundle
in "/home/bertrand/www/ezpublish5/src/" using the "yml" format.
Do you confirm generation [yes]?<enter>
=20

After generation, the wizard will offer to update the kernel with our bu= ndle (answer "yes"), and to update the app=E2=80=99s routing with our bundl= e=E2=80=99s route file (answer "no").

=20
Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic update of your Kernel [yes]? <enter>
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? no <enter>

=20

Our bundle should now be generated. Navigate to src/EzSystems/EzSy= stemsTweetBundle and you should see the following structure:

=20
$ ls -l src/EzSystems/TweetFieldTypeBundle
Controller
DependencyInjection
EzSystemsTweetFieldTypeBundle.php
Resources
Tests
=20

Feel free to delete the Controller folder, since we won=E2=80=99t use it= in this tutorial. It could have been useful, had our Field Type required a= n interface of its own.

=20
=20
=20
=20
Tutorial path
=20

=20
    =20
    =20
    =20
=20
=20 =20 = =20 =20 =20 =20 =20 =20 =20 = =20 =20 =20 =20 =20
=20 =20
=20
=20
=20

=20
=20
=20
=20
------=_Part_3767_1365283579.1485855268735--