The first thing to do is create the template. It will basically define the default display of a tweet. Remember that field type templates can be overridden in order to tweak what is displayed and how.

Each Field Type template receives a set of variables that can be used to achieve the desired goal. The variable you care about is field, an instance of eZ\Publish\API\Repository\Values\Content\Field. In addition to its own metadata (id, fieldDefIdentifier, etc.), it exposes the Field Value (Tweet\Value) through the value property.

field.value.contents is piped through the raw twig operator, since the variable contains HTML code. Without it, the HTML markup would be visible directly, since twig escapes variables by default. Notice that the code is nested within a spaceless tag, so that you can format the template in a readable manner without jeopardizing the display with unwanted spaces.

Even though the above will work just fine, a few helpers will enable you to get something a bit more flexible. The EzPublishCoreBundle::content_fields.html.twig template, where the native Field Type templates are implemented, provides a few helpers: simple_block_field, simple_inline_field and field_attributes. The first two are used to display a field either as a block or inline. field_attributes makes it easier to use the attr variable that contains additional (HTML) attributes for the field.

Let's try to display the value as a block element.

First, you need to make the template inherit from content_fields.html.twig. Then, create a field_value variable that will be used by the helper to print out the content inside the markup. And that's it. The helper will use field_attributes to add the HTML attributes to the generated div.

As explained in the FieldType template documentation, a Field Type template needs to be registered in the eZ Platform semantic configuration. The most basic way to do this would be to do so in app/config/ezplatform.yml:

However, this is far from ideal. You want this to be part of our bundle, so that no manual configuration is required. For that to happen, you need to make the bundle extend the eZ Platform semantic configuration.

To do so, you are going to make your Bundle's dependency injection extension (DependencyInjection/EzSystemsTweetFieldTypeExtension.php) implement Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface. This interface will let you prepend bundle configuration: