diff --git a/src/Importer.php b/src/Importer.php index ba8d4d4..58fafb0 100644 --- a/src/Importer.php +++ b/src/Importer.php @@ -5,7 +5,6 @@ namespace Drupal\default_content; use Drupal\Component\Graph\Graph; use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\default_content\Event\DefaultContentEvents; use Drupal\default_content\Event\ImportEvent; @@ -126,8 +125,8 @@ class Importer implements ImporterInterface { * Path to a module's content folder. */ protected function buildGraph($folder) { - foreach ($this->entityManager->getDefinitions() as $entity_type) { - $this->addEntities($folder, $entity_type); + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { + $this->addEntities($folder, $entity_type_id); } } @@ -136,25 +135,25 @@ class Importer implements ImporterInterface { * * @param string $folder * Path to a module's content directory. - * @param EntityTypeInterface $entity_type - * Entity type to be imported. + * @param string $entity_type_id + * Entity type id to be imported. */ - protected function addEntities($folder, EntityTypeInterface $entity_type) { + protected function addEntities($folder, $entity_type_id) { $reflection = new \ReflectionClass($entity_type->getClass()); // We are only interested in importing content entities. if ($reflection->implementsInterface(ConfigEntityInterface::class)) { continue; } - if (!file_exists($folder . '/' . $entity_type->id())) { + if (!file_exists($folder . '/' . $entity_type_id)) { continue; } - $files = $this->scanner()->scan($folder . '/' . $entity_type->id()); + $files = $this->scanner()->scan($folder . '/' . $entity_type_id); // Default content uses drupal.org as domain. // @todo Make this use a uri like default-content:. $this->linkManager->setLinkDomain(static::LINK_DOMAIN); // Parse all of the files and sort them in order of dependency. foreach ($files as $file) { - $this->addFile($file, $entity_type); + $this->addFile($file); } } @@ -164,10 +163,8 @@ class Importer implements ImporterInterface { * @param stdClass $file * stdClass object with name and uri properties, as returned by * DefaultContentScanner::scan - * @param EntityTypeInterface $entity_type - * Entity type associated with the given file. */ - protected function addFile($file, EntityTypeInterface $entity_type) { + protected function addFile($file) { $contents = $this->parseFile($file); // Decode the file contents. $decoded = $this->serializer->decode($contents, 'hal_json'); @@ -187,7 +184,7 @@ class Importer implements ImporterInterface { } // Store the entity type with the file. - $file->entity_type_id = $entity_type->id(); + $file->entity_type_id = $entity_type_id; // Store the file in the file map. $this->fileMap[$item_uuid] = $file; // Create a vertex for the graph.