Step 1 - Create the bundle¶
You can find all files used and modified in this step on GitHub.
FieldTypes, like any other eZ Platform extensions, must be provided as Symfony bundles. This chapter covers the creation and organization of this bundle.
Once you have installed eZ Platform, including the creation of a database for the tutorial, configured a server, and started the web server, you need to create a code base for the tutorial.
The Field Type will be placed in a Symfony bundle. You can get started with a bundle using the built-in Symfony bundle generator. Then you will configure the bundle to be able to write the code you need to create a Field Type.
Generate the bundle¶
From the eZ Platform root, run the following:
Our bundle should now be generated. Navigate to
src/EzSystems/TweetFieldTypeBundle and you should see the following structure:
1 2 3 4 5 6
generate:bundle command returns an error about registering the bundle namespace in
composer.json, add the following line to the
composer.json file within the
Then execute the following command to regenerate the autoload files:
Feel free to delete the Controller folder, since you won’t use it in this tutorial. It could have been useful, had our Field Type required an interface of its own.
Also, you can safely delete the
Resources/views/Default folder and
Resources/config/routing.yml file, as they won't be needed. You should remove the
ez_systems_tweet_field_type entry from the
app/config/routing.yml file as well.
Structure the bundle¶
At this point, you have a basic application-specific Symfony bundle. First you will create the structure for the Field Type.
To make it easier to move around the code, you will to some extent mimic the structure that is used in the kernel of eZ Platform. Native Field Types are located inside
vendor/ezsystems), in the
Each Field Type has its own subfolder:
You will use a structure quite close to this:
From the tutorial git repository, list the contents of the
Now prepare the files for two classes you will need for the Field Type:
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9