InstallHelper
class InstallHelper implements ContainerInjectionInterface (View source)
| internal | This code is only for use by the Umami demo: Content module. |
Defines a helper class for importing default content.
Properties
| protected AliasManagerInterface | $aliasManager | The path alias manager. |
|
| protected EntityTypeManagerInterface | $entityTypeManager | Entity type manager. |
|
| protected ModuleHandlerInterface | $moduleHandler | Module handler. |
|
| protected StateInterface | $state | State. | |
| protected FileSystemInterface | $fileSystem | The file system. |
|
| protected array | $enabledLanguages | Enabled languages. |
|
| protected array | $termIdMap | Term ID map. |
|
| protected array | $mediaImageIdMap | Media Image CSV ID map. |
|
| protected array | $nodeIdMap | Node CSV ID map. |
Methods
Constructs a new InstallHelper object.
Instantiates a new instance of this class.
Imports default contents.
Set module_path variable.
Read multilingual content.
Retrieves the Term ID of a term saved during the import process.
Saves a Term ID generated when saving a taxonomy term.
Retrieves the Media Image ID of a media image saved during the import process.
Saves a Media Image ID generated when saving a media image.
Retrieves the node path of node CSV ID saved during the import process.
Saves a node CSV ID generated when saving content.
Imports editors.
Process terms for a given vocabulary and filename.
Process images into media entities.
Process pages data into page node structure.
Process recipe data into recipe node structure.
Process article data into article node structure.
Process block_banner data into block_banner block structure.
Process disclaimer_block data into disclaimer_block block structure.
Process footer_block data into footer_block block structure.
Process content into a structure that can be saved into Drupal.
Imports content.
Deletes any content imported by this module.
Looks up a user by name, if it is missing the user is created.
Creates a file entity based on an image path.
Stores record of content entities created by this import.
Details
__construct(AliasManagerInterface $aliasManager, EntityTypeManagerInterface $entityTypeManager, ModuleHandlerInterface $moduleHandler, StateInterface $state, FileSystemInterface $fileSystem)
Constructs a new InstallHelper object.
static
create(ContainerInterface $container)
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
importContent()
Imports default contents.
protected $this
getModulePath()
Set module_path variable.
protected array
readMultilingualContent(string $filename)
Read multilingual content.
protected int
getTermId(string $vocabulary, int $term_csv_id)
Retrieves the Term ID of a term saved during the import process.
protected
saveTermId(string $vocabulary, int $term_csv_id, int $tid)
Saves a Term ID generated when saving a taxonomy term.
protected int
getMediaImageId(int $media_image_csv_id)
Retrieves the Media Image ID of a media image saved during the import process.
protected
saveMediaImageId(int $media_image_csv_id, int $media_image_id)
Saves a Media Image ID generated when saving a media image.
protected string
getNodePath(string $langcode, string $content_type, string $node_csv_id)
Retrieves the node path of node CSV ID saved during the import process.
protected
saveNodePath(string $langcode, string $content_type, string $node_csv_id, string $node_url)
Saves a node CSV ID generated when saving content.
protected $this
importEditors()
Imports editors.
Other users are created as their content is imported. However, editors don't have their own content so are created here instead.
protected array
processTerm(array $data, string $vocabulary)
Process terms for a given vocabulary and filename.
protected array
processImage(array $data)
Process images into media entities.
protected array
processPage(array $data, string $langcode)
Process pages data into page node structure.
protected array
processRecipe(array $data, string $langcode)
Process recipe data into recipe node structure.
protected array
processArticle(array $data, string $langcode)
Process article data into article node structure.
protected array
processBannerBlock(array $data, string $langcode)
Process block_banner data into block_banner block structure.
protected array
processDisclaimerBlock(array $data)
Process disclaimer_block data into disclaimer_block block structure.
protected array
processFooterPromoBlock(array $data, string $langcode)
Process footer_block data into footer_block block structure.
protected array
processContent(string $bundle_machine_name, array $content, string $langcode)
Process content into a structure that can be saved into Drupal.
protected $this
importContentFromFile(string $entity_type, string $bundle_machine_name)
Imports content.
$this
deleteImportedContent()
Deletes any content imported by this module.
protected int
getUser(string $name)
Looks up a user by name, if it is missing the user is created.
protected int
createFileEntity(string $path)
Creates a file entity based on an image path.
protected
storeCreatedContentUuids(array $uuids)
Stores record of content entities created by this import.