Best SEO Services Company in Dallas | Best SEO Agency Dallas
Drupal 8: Entities
1. Drupal 8: EntitiesDrupal 8: Entities
Working with entities in Drupal 8 modulesWorking with entities in Drupal 8 modules
Drupal Meetup StuttgartDrupal Meetup Stuttgart
06/11/2015
3. “ loadable thingies, thatloadable thingies, that
can optionally be fieldablecan optionally be fieldable
https://www.drupal.org/node/460320
Entities areEntities are
4. Entity types - node, user, ...
-> Base fields, like nid, title, author
Bundles - article, story, ...
-> Bundle fields, like an image
All entities aren't equal, they may haveAll entities aren't equal, they may have
differentdifferent
5. Entities in Drupal 7 (Core)Entities in Drupal 7 (Core)
Nodes
Users
Taxonomy vocabularies
Taxonomy terms
Files
Comments
6. Entities in Drupal 8Entities in Drupal 8
Entities in Drupal 8 are classes
Can be content entities or config entities
Extend corresponding base classes
class Contact extends ContentEntityBase implements ContactInterface {
...
}
7. Entity examples in Drupal 8 (Core)Entity examples in Drupal 8 (Core)
Content Entities Configuration entities
Aggregator feed / item
Block content
Comment
Message
File
Menu link
Content (aka node)
Shortcut
Taxonomy term
User
Action
Block
Breakpoint
Comment type
Content type
Date format
Field
Image Style
Language
Menu
Role
View
...
10. The problem with D7:The problem with D7:
Entity API is incomplete, only the R exists (entity_load)
Most missing parts implemented by contrib (entity module)
But many developers keep using proprietary D6 functions,
still not removed from core:
- node_load(), node_save()
- user_load(), user_save()
- taxonomy_get_term_by_name()
- taxonomy_vocabulary_delete()
- ...
11. Drupal 8: Entity API in core!Drupal 8: Entity API in core!
Streamlines the way of working with entities
Easy extendable / testable (OOP)
No need for proprietary stuff
26. Drupal 7: Entity Field QueryDrupal 7: Entity Field Query
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', array('product', 'movies'))
->propertyCondition('status', 1)
->fieldCondition('body', 'value', 'discount', 'CONTAINS')
->propertyOrderBy('created', 'DESC');
$result = $query->execute();
if (!empty($result['node'])) {
$nodes = node_load_multiple(array_keys($result['node']))
}
Useful, but
why is this called Entity Field Query?
why are there three condition types?
what's the result structure?