diff --git a/src/Importer.php b/src/Importer.php index e062781..e32e28a 100644 --- a/src/Importer.php +++ b/src/Importer.php @@ -128,9 +128,17 @@ class Importer implements ImporterInterface { /** * {@inheritdoc} */ - public function importContent($module) { + public function importContent($source) { $created = []; - $folder = drupal_get_path('module', $module) . "/content"; + $isModuleImport = \Drupal::moduleHandler()->moduleExists($source); + + if ($isModuleImport) { + $module = $source; + $folder = drupal_get_path('module', $module) . "/content"; + } + else { + $folder = $source; + } if (file_exists($folder)) { $root_user = $this->entityTypeManager->getStorage('user')->load(1); @@ -248,7 +256,7 @@ class Importer implements ImporterInterface { $created[$entity->uuid()] = $entity; } } - $this->eventDispatcher->dispatch(DefaultContentEvents::IMPORT, new ImportEvent($created, $module)); + $this->eventDispatcher->dispatch(DefaultContentEvents::IMPORT, new ImportEvent($created, $source)); $this->accountSwitcher->switchBack(); } // Reset the tree. diff --git a/src/ImporterInterface.php b/src/ImporterInterface.php index 0d300a3..190ad37 100644 --- a/src/ImporterInterface.php +++ b/src/ImporterInterface.php @@ -8,14 +8,14 @@ namespace Drupal\default_content; interface ImporterInterface { /** - * Imports default content from a given module. + * Imports default content from a given source. * - * @param string $module - * The module to create the default content from. + * @param string $source + * The module or folder path to create the default content from. * * @return \Drupal\Core\Entity\EntityInterface[] * An array of created entities keyed by their UUIDs. */ - public function importContent($module); + public function importContent($source); }