Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Skip to end of metadata
Go to start of metadata

Custom FieldTypes follow the Symfony 2 extension mechanism: bundles. We can get started with a bundle using the built-in Symfony 2 bundle generator.

Generating the bundle

From the eZ  Publish 5 root, run the following:

First, we are asked for the namespace. As the vendor, we will use EzSystems as the root namespace. This must of course be changed to whatever identifies you as a vendor (your name, company name, etc). We then choose a preferably unique name for the field type itself, and make the name end with Bundle. I’ve chosen TweetFieldTypeBundle.

 

We must next input the bundle’s name. Nothing exotic here: we concatenate the vendor’s namespace and the bundle’s namespace, which is the default. We just hit enter:

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 moved to vendor at some point. Again, this is the default, and we just hit enter.

We must then specify which format the generation must be generated as. We will use yml, since it is what we use in eZ Publish 5 itself. Of course, any other format could have been used.

The generator will then offer us to generate the whole directory structure for us. Since our bundle isn’t really a standard Symfony full stack bundle, we decline.

We then get a summary of what will be generated:

 

After generation, the wizard will offer us to update the kernel with our bundle (yes please), and to update the app’s routing with our bundle’s route file (no thanks).

Our bundle should have been generated. Navigate to src/EzSystems/EzSystemsTweetBundle, and you should see this structure:


 Feel free to delete the Controller folder, since we won’t use it in this tutorial. It could have been useful had our field type required an interface of its own.

2 Comments

  1. it has to be "generate:bundle" not "bundle:generate"

    php ezpublish/console generate:bundle

  2. Hello,

    Now it's possible to know how to change de default pagelayout demo and use my new bundle please.

    I'm totally new in eZpublish 5x i don't know where change my settings.

    Thanks lot