Build your datatypes
About me•   Edi Modrić•   Computer engineering masters degree•   Working at Netgen for 5 years    •   1 year of .Net devel...
Agenda•   Primary agendas    •   Build a field type using public API    •   Test the hell out of it•   Secondary agendas (...
Workshop•   One hour of coding    •   Try to build the field type and test it•   Ideas    •   Try to port your existing da...
What is a datatype?•   Base building block of all content in eZ Publish    •   Collection of methods to store, read and va...
What is a datatype?
Datatype + public API = field type•   Initial idea was to demo the eZ Tags datatype    •   Complicated    •   We’re time l...
Datatype + public API = field type•   Content class = Content type•   Content object = Content•   Content class attribute ...
Datatype + public API = field type•   $ cd /var/www/ezp-next/•   $ rm –rf settings/•   $ git remote add emodric    https:/...
Datatype + public API = field type
Datatype + public API = field type•   eZPublishSPIFieldTypeFieldType    •   getFieldTypeIdentifier    •   acceptValue / ge...
Datatype + public API = field type•   eZPublishSPIFieldTypeFieldStorage    •   storeFieldData    •   getFieldData    •   d...
Datatype + public API = field type•   eZPublishCoreFieldTypeFieldType    •   Abstract that implements …SPIFieldTypeFieldTy...
Datatype + public API = field type•   eZPublishCoreFieldTypeValue    •   Abstract for field value    •   Optional, but sho...
“I thought I fixed that” - why testing matters•   Testing is an integral part of any software development     •   Keeps yo...
“I thought I fixed that” - why testing matters•   Testing field type integration with public API     •   Using real world ...
What about legacy stack?•   Legacy datatypes are not going anywhere    •   No admin interface based on Symfony stack    • ...
Field type vs. datatype•   No difference in functionality•   Advantages over datatypes is obvious    •   Much much much ea...
Q&A42Edi Modrić  emodricedi@netgen.hr
Upcoming SlideShare
Loading in …5
×

Build your datatypes

1,216 views
1,044 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,216
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Build your datatypes

  1. 1. Build your datatypes
  2. 2. About me• Edi Modrić• Computer engineering masters degree• Working at Netgen for 5 years • 1 year of .Net development • 4 years of eZ Publish development • Certified eZ Publish developer • eZ Tags maintainer • Collaborating with eZ Systems on ezp-next for 8 months• @emodric• edi@netgen.hr
  3. 3. Agenda• Primary agendas • Build a field type using public API • Test the hell out of it• Secondary agendas (if time permits) • Comparison to legacy datatypes • Integration with eZ Publish 5 using Symfony
  4. 4. Workshop• One hour of coding • Try to build the field type and test it• Ideas • Try to port your existing datatype OR • Try to modify the one presented today OR • Some examples • Storing dates < 1.1.1970 • Storing and validating IP address • Storing and validating social security number • …• Work in groups, help each other
  5. 5. What is a datatype?• Base building block of all content in eZ Publish • Collection of methods to store, read and validate content• Object oriented architecture of content model• Class – blueprint of a single piece of content • Collection of class attributes, which are of some (data)type• Object – a single piece of content • Instance of a class • Collection of object attributes, values of class attribute
  6. 6. What is a datatype?
  7. 7. Datatype + public API = field type• Initial idea was to demo the eZ Tags datatype • Complicated • We’re time limited• eZ Publish 5 is nearly here • Demo the future, not the past
  8. 8. Datatype + public API = field type• Content class = Content type• Content object = Content• Content class attribute = Field definition• Content object attribute = Field• Object attribute content = Field value• Datatype = Field type
  9. 9. Datatype + public API = field type• $ cd /var/www/ezp-next/• $ rm –rf settings/• $ git remote add emodric https://github.com/emodric/ezp- next.git• $ git checkout -b nginteger• $ git pull emodric nginteger• $ php composer.phar update --dev• $ ./Netgen/runtests.sh
  10. 10. Datatype + public API = field type
  11. 11. Datatype + public API = field type• eZPublishSPIFieldTypeFieldType • getFieldTypeIdentifier • acceptValue / getEmptyValue • fromHash / toHash • fromPersistenceValue / toPersistenceValue • getSettingsSchema / getValidatorConfigurationSchema • validateFieldSettings / validateValidatorConfiguration • validate • getName • isSearchable
  12. 12. Datatype + public API = field type• eZPublishSPIFieldTypeFieldStorage • storeFieldData • getFieldData • deleteFieldData • hasFieldData • getIndexData• eZPublishSPIFieldTypeIndexable• eZPublishSPIFieldTypeValidationError
  13. 13. Datatype + public API = field type• eZPublishCoreFieldTypeFieldType • Abstract that implements …SPIFieldTypeFieldType • Default behavior of some methods + validator handling• eZPublishCoreFieldType[GatewayBasedStorage|Null Storage] • Abstracts that implement …SPIFieldTypeFieldStorage• eZPublishCoreFieldTypeStorageGateway • Abstract for gateways to external storage • used by GatewayBasedStorage
  14. 14. Datatype + public API = field type• eZPublishCoreFieldTypeValue • Abstract for field value • Optional, but should be included• eZPublishCoreFieldTypeValidationError • Implementation of …SPIFieldTypeValidationError• eZPublishCoreFieldTypeValidator • Abstract for all validators to extend• eZPublishCoreFieldTypeFileService
  15. 15. “I thought I fixed that” - why testing matters• Testing is an integral part of any software development • Keeps your code rock solid • Feature and future proof • Gives you a piece of mind• Testing framework in ezp-next is preconfigured BUT • One „hack” is needed if you’re using external storage • Updating database schema fixtures • eZPublishCorePersistenceLegacyTests_fixtures schema.sqlite.sql • Dependency injection configuration
  16. 16. “I thought I fixed that” - why testing matters• Testing field type integration with public API • Using real world implementation of repository • Tests if our field type plays well with others• Testing field type integration with persistence SPI • Hooks directly into persistence implementation • Tests if our field type stores and loads data correctly• Unit testing of the field type • Tests the field type methods (units), one by one
  17. 17. What about legacy stack?• Legacy datatypes are not going anywhere • No admin interface based on Symfony stack • To actually use your field type, you WILL need legacy datatype• https://github.com/emodric/nginteger.git • Legacy datatype prepared for comparison
  18. 18. Field type vs. datatype• No difference in functionality• Advantages over datatypes is obvious • Much much much easier testing • Clear separation of concerns • No POST variables • No SQL • No file uploads • More readable and understandable code • Object oriented code
  19. 19. Q&A42Edi Modrić emodricedi@netgen.hr

×