public function EntityContext::save in Lightning Core 8.2
Same name and namespace in other branches
- 8.5 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::save()
- 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::save()
- 8.3 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::save()
- 8.4 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::save()
Saves an entity, ensuring automatic clean-up.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
1 call to EntityContext::save()
- EntityContext::createMultiple in tests/
contexts/ EntityContext.behat.inc - Creates a set of entities from tabular data.
File
- tests/
contexts/ EntityContext.behat.inc, line 37
Class
- EntityContext
- Contains miscellaneous step definitions for working with Drupal entities.
Namespace
Acquia\LightningExtension\ContextCode
public function save(EntityInterface $entity) {
$uid = $this
->getUser();
if ($uid && $entity instanceof EntityOwnerInterface && $entity
->getOwnerId() == 0) {
$entity
->setOwnerId($uid)
->save();
}
else {
$entity
->save();
$entity_type = $entity
->getEntityTypeId();
$this->trash[$entity_type][] = $entity
->id();
}
}