function EntityAdapter::createFromEntity
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php \Drupal\Core\Entity\Plugin\DataType\EntityAdapter::createFromEntity()
- 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php \Drupal\Core\Entity\Plugin\DataType\EntityAdapter::createFromEntity()
- 11.x core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php \Drupal\Core\Entity\Plugin\DataType\EntityAdapter::createFromEntity()
Creates an instance wrapping the given entity.
Parameters
\Drupal\Core\Entity\EntityInterface|null $entity: The entity object to wrap.
Return value
static
5 calls to EntityAdapter::createFromEntity()
- EntityAdapterUnitTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Entity/ TypedData/ EntityAdapterUnitTest.php - EntityContextDefinition::getSampleValues in core/
lib/ Drupal/ Core/ Plugin/ Context/ EntityContextDefinition.php - Returns typed data objects representing this context definition.
- RecursiveContextualValidatorTest::testRecursiveValidate in core/
tests/ Drupal/ KernelTests/ Core/ TypedData/ RecursiveContextualValidatorTest.php - Tests recursive validation against given constraints against an entity.
- TemporaryJsonapiFileFieldUploader::handleFileUploadForField in core/
modules/ jsonapi/ src/ Controller/ TemporaryJsonapiFileFieldUploader.php - Creates and validates a file entity for a file field from a file stream.
- TemporaryJsonapiFileFieldUploader::validate in core/
modules/ jsonapi/ src/ Controller/ TemporaryJsonapiFileFieldUploader.php - Validates the file.
File
-
core/
lib/ Drupal/ Core/ Entity/ Plugin/ DataType/ EntityAdapter.php, line 46
Class
- EntityAdapter
- Defines the "entity" data type.
Namespace
Drupal\Core\Entity\Plugin\DataTypeCode
public static function createFromEntity(EntityInterface $entity) {
$definition = EntityDataDefinition::create()->setEntityTypeId($entity->getEntityTypeId())
->setBundles([
$entity->bundle(),
]);
$instance = new static($definition);
$instance->setValue($entity);
return $instance;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.