Chris@0: $this->types]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getBundleMapping() { Chris@0: if (!empty($this->types)) { Chris@0: return ['types' => $this->types]; Chris@0: } Chris@0: return []; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setBundleMapping(array $mapping) { Chris@0: if (isset($mapping['types'])) { Chris@0: $this->types = $mapping['types']; Chris@0: } Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getPreparedFieldMapping($field_name) { Chris@0: $field_mapping = [ Chris@0: 'properties' => NULL, Chris@0: 'datatype' => NULL, Chris@0: 'datatype_callback' => NULL, Chris@0: 'mapping_type' => NULL, Chris@0: ]; Chris@0: if (isset($this->fieldMappings[$field_name])) { Chris@0: $field_mapping = array_merge($field_mapping, $this->fieldMappings[$field_name]); Chris@0: } Chris@0: return empty($field_mapping['properties']) ? [] : $field_mapping; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getFieldMapping($field_name) { Chris@0: if (isset($this->fieldMappings[$field_name])) { Chris@0: return $this->fieldMappings[$field_name]; Chris@0: } Chris@0: return []; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setFieldMapping($field_name, array $mapping = []) { Chris@0: $this->fieldMappings[$field_name] = $mapping; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function id() { Chris@0: return $this->targetEntityType . '.' . $this->bundle; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function calculateDependencies() { Chris@0: parent::calculateDependencies(); Chris@0: Chris@0: // Create dependency on the bundle. Chris@0: $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); Chris@0: $this->addDependency('module', $entity_type->getProvider()); Chris@0: $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->bundle); Chris@0: $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function postSave(EntityStorageInterface $storage, $update = TRUE) { Chris@0: parent::postSave($storage, $update); Chris@0: Chris@0: if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) { Chris@0: \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); Chris@0: } Chris@0: } Chris@0: Chris@0: }