12
s s

eZ Unconference#2 - Fieldtype - A. Rømcke

Embed Size (px)

DESCRIPTION

eZ Unconference

Citation preview

Page 1: eZ Unconference#2 - Fieldtype - A. Rømcke

s s

Page 2: eZ Unconference#2 - Fieldtype - A. Rømcke

What is a Field Type

• Base building block of all content in eZ Publish • Collection of methods to store, read and validate content

• Object oriented architecture of content model

• Content type – blueprint of a single piece of content • Collection of class attributes, which are of some (data)type

• Content – a single piece of content • Instance of a class • Collection of Fields, values of FieldDefinitions

Page 3: eZ Unconference#2 - Fieldtype - A. Rømcke

What is a datatype (aka FieldType)

Page 4: eZ Unconference#2 - Fieldtype - A. Rømcke

Updated Glossary

eZ Publish 4 eZ Publish 5 Content object Content Content class Content Type Content object attribute Field Content class attribute Field Definition Object attribute content Field Value Datatype Field Type

Page 5: eZ Unconference#2 - Fieldtype - A. Rømcke

How it is consumed

Page 6: eZ Unconference#2 - Fieldtype - A. Rømcke

FieldType API

eZ\Publish\SPI\FieldType\FieldType • getFieldTypeIdentifier • acceptValue / getEmptyValue • fromHash / toHash • fromPersistenceValue / toPersistenceValue • getSettingsSchema /

getValidatorConfigurationSchema • validateFieldSettings / validateValidatorConfiguration • validate • getName • isSearchable

Page 7: eZ Unconference#2 - Fieldtype - A. Rømcke

FieldType SPI (interfaces to implement)

•eZ\Publish\SPI\FieldType\FieldStorage • storeFieldData • getFieldData • deleteFieldData • hasFieldData • getIndexData

•eZ\Publish\SPI\FieldType\Indexable

•eZ\Publish\SPI\FieldType\ValidationError

Page 8: eZ Unconference#2 - Fieldtype - A. Rømcke

FieldType API abstract classes

eZ\Publish\Core\FieldType\FieldType • Abstract that implements …\SPI\FieldType\FieldType • Default behavior of some methods + validator handling

Needed for Legacy Storage Engine:

eZ\Publish\Core\FieldType\GatewayBasedStorage • Abstract that implements …\SPI\FieldType\FieldStorage

eZ\Publish\Core\FieldType\StorageGateway

• Abstract for gateways to external storage • Used by GatewayBasedStorage

eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Con

verter

Page 9: eZ Unconference#2 - Fieldtype - A. Rømcke

FieldType API abstract classes #2

•eZ\Publish\Core\FieldType\Value • Abstract for field value

•eZ\Publish\Core\FieldType\ValidationError

• Implementation of …\SPI\FieldType\ValidationError

•eZ\Publish\Core\FieldType\Validator

• Abstract for all validators to extend

•eZ\Publish\Core\IO\IOService • Binary files IO handling

Page 10: eZ Unconference#2 - Fieldtype - A. Rømcke

FieldType standardized unit/integration tests

•API integration tests

• Using real world implementation of repository • Tests if our field type plays well with others • eZ\Publish\API\Repository\Tests\FieldType\TextLineIntegrationTest.php

•SPI integration tests • Hooks directly into persistence implementation • Tests if our field type stores and loads data correctly • eZ\Publish\SPI\Tests\FieldType\TextLineIntegrationTest.php

•Unit testing of the field type • Tests the field type methods (units), one by one • eZ\Publish\Core\FieldType\Tests\TextLineTest.php

•TDD is your friend. Really!

Page 11: eZ Unconference#2 - Fieldtype - A. Rømcke

What about BC

•Right now: Think dual kernel

• Datatype [legacy] for the backoffice

• FieldType [5.x] for the front

•Yes, you currently have to write both

Page 12: eZ Unconference#2 - Fieldtype - A. Rømcke

The end

?

Twitter: @bdunogier & @andrerom Google+: http://gplus.to/BertrandDunogier SlideShare: http://slideshare.net/BertrandDunogier