Created
October 11, 2016 08:41
-
-
Save bratsun/15f7a8da58b3f65444b9d4c4acbab69a to your computer and use it in GitHub Desktop.
Complete entity routing and operations (http://wizzlern.nl/sites/wizzlern.nl/files/artikel/drupal-content-entity-8.0.pdf)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create and save | |
$entity = Entity::create($values); | |
$entity = Entity::load($id); | |
$entities = Entity::loadMultiple($ids); | |
$entity->save(); | |
$entity->delete(); | |
$entity_id = $entity->id(); | |
$bundle = $entity->bundle(); | |
// load and perform operations or get data | |
$node = $this->entityTypeManager | |
->getStorage('node') | |
->load($nid); | |
$node = Node::load($nid); | |
$node->save(); | |
$node->delete(); | |
$node_type = $node->getType(); | |
$title = $node->getTitle(); | |
$visible = $node->isPublished(); | |
$node->setPromoted(TRUE); | |
$uid = $node->getOwnerId(); | |
$author = $node->getOwner(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment