getPropertiesToExport example

'provider' => 'views', 'id' => 'view'], 'views.view'],
    ];
  }

  /** * @covers ::getPropertiesToExport * * @dataProvider providerGetPropertiesToExport */
  public function testGetPropertiesToExport($definition$expected) {
    $entity_type = $this->setUpConfigEntityType($definition);
    $properties_to_export = $entity_type->getPropertiesToExport();
    $this->assertSame($expected$properties_to_export);

    // Ensure the method is idempotent.     $properties_to_export = $entity_type->getPropertiesToExport();
    $this->assertSame($expected$properties_to_export);
  }

  public function providerGetPropertiesToExport() {
    $data = [];
    $data[] = [
      [
        

  public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values) {
    $entity->original = clone $entity;

    $data = $this->mapFromStorageRecords([$values]);
    $updated_entity = current($data);

    /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */
    $entity_type = $this->getEntityType();
    $id_key = $entity_type->getKey('id');
    $properties = $entity_type->getPropertiesToExport($updated_entity->get($id_key));

    if (empty($properties)) {
      // Fallback to using the provided values. If the properties cannot be       // determined for the config entity type annotation or configuration       // schema.       $properties = array_keys($values);
    }
    foreach ($properties as $property) {
      if ($property === $this->uuidKey) {
        // During an update the UUID field should not be copied. Under regular         // circumstances the values will be equal. If configuration is written


  /** * {@inheritdoc} */
  public function toArray() {
    $properties = [];
    /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */
    $entity_type = $this->getEntityType();

    $id_key = $entity_type->getKey('id');
    $property_names = $entity_type->getPropertiesToExport($this->id());
    if (empty($property_names)) {
      throw new SchemaIncompleteException(sprintf("Entity type '%s' is missing 'config_export' definition in its annotation", $entity_type->getClass()));
    }
    foreach ($property_names as $property_name => $export_name) {
      // Special handling for IDs so that computed compound IDs work.       // @see \Drupal\Core\Entity\EntityDisplayBase::id()       if ($property_name == $id_key) {
        $properties[$export_name] = $this->id();
      }
      else {
        $properties[$export_name] = $this->get($property_name);
      }
protected function getAllFieldNames(EntityTypeInterface $entity_type$bundle) {
    if ($entity_type instanceof ContentEntityTypeInterface) {
      $field_definitions = $this->entityFieldManager->getFieldDefinitions(
        $entity_type->id(),
        $bundle
      );
      return array_keys($field_definitions);
    }
    elseif ($entity_type instanceof ConfigEntityTypeInterface) {
      // @todo Uncomment the first line, remove everything else once https://www.drupal.org/project/drupal/issues/2483407 lands.       // return array_keys($entity_type->getPropertiesToExport());       $export_properties = $entity_type->getPropertiesToExport();
      if ($export_properties !== NULL) {
        return array_keys($export_properties);
      }
      else {
        return ['id', 'type', 'uuid', '_core'];
      }
    }
    else {
      throw new \LogicException("Only content and config entity types are supported.");
    }
  }

  
Home | Imprint | This part of the site doesn't use cookies.