Aug
17
2016
By abernal
Note from a webinar in Drupal Development
Mad with Power
Drupal 8 is more intuitive
Code
https://github.com/tedbow/Drupal-8-Power
Contains all the indivudual modules that Ted Bowman will present.
Topics
- OOP
- Importance of IDE
- Base Fields
- Extending Classes
OOP
More complicated but
- More encapsulated
- More self documented
- Easier to learn
IDE
IntelliJ
PhpStorm
Base Fields
Everything is a field in drupal 8
- Node : author, created, changed, content type
- User : name, mail, password, roles
Advantages
- Use field widgets
- Formatters
- Configurable
Node Author
- Entity reference to user
- Can use all entity reference
- formatters
User Roles
- Entity reference to a role (config entity)
- Can use all entity reference
- Formatters
- Widgets
- Form : not configurable
- View: not configurable
Example Module : Real Author
Tracks who really wrote content
Separates drupal user from author
Adds new base entity reference field
- Target type : user
- Could use content
Remove editing and configuration of author field
Example Module : Show User Fields
Makes hidden user base fields
- Viewable
- Configurable
Fields
- Roles
- Last Login
- Last Access
Implement
- hook_entity_base_field_info_alter
- Change field to be configurable
- OOP
- use old school hooks
- Benefits from drupal 8
Example Module: No Access Reference Label
Allow view of referenced entities labels without entity view access
Links to viewable entities
Acts like author label for other references
Implementing Plugin
Where to Start
- Find a similar plugin
- Can you extend it
- Can you extend its parent