- 🇵🇱Poland Luke_Nuke
I apologize for a very late respond, but better late than never. Nids absolutely can be static. You just need to set ID of the entity before saving it, and it will be saved under this ID.
I think the module is a bit radical when you execute the command 'drush content-fixtures:load' as it purges all datas prior to load the fixtures.
Maybe I'm thinking wrong here as I am new to the fixtures concept. From what I understand is to create stable content to run tests. I'm trying to implement it on an existing Drupal Website that has a lot of content and entity types. What's the best practice here ? Have an empty version of the same website to run tests with fixtures ?
Here is just a version with purge at true or false. But we could also have an option like 'append' to just append content.
/**
* Load all fixtures.
*
* @command content-fixtures:load
* @aliases content-fixtures-load
* @option groups
* @option purge
* @usage drush content-fixtures:load
* Loads all fixtures.
* @usage drush content-fixtures:load --groups=group1,group2,group3
* Loads fixtures belonging to three groups.
*
* @validate-module-enabled content_fixtures
*/
public function load($options = ['groups' => InputOption::VALUE_REQUIRED, 'purge' => TRUE]) {
if (!empty($options['groups'])) {
$groups = explode(',', $options['groups']);
$this->output()->writeln('Selected groups: ' . implode(', ', $groups));
}
if ($options['purge'] === TRUE) {
if (!$this->io()->confirm('Are you sure you want to delete all existing content and load fixtures?', FALSE)) {
return;
}
$this->output()->writeln('Deleting existing content.');
$this->purger->purge();
}
$fixtures = $this->fixturesLoader->getFixtures();
if (empty($fixtures)) {
$this->output()->writeln('No fixtures found.');
return;
}
foreach ($fixtures as $fixture) {
if (isset($groups) && (!$fixture instanceof FixtureGroupInterface || empty(array_intersect($groups, $fixture->getGroups())))) {
continue;
}
$this->output()->writeln('Loading fixture: ' . \get_class($fixture));
$fixture->load();
}
$this->output()->writeln('Done.');
}
Postponed: needs info
3.1
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I apologize for a very late respond, but better late than never. Nids absolutely can be static. You just need to set ID of the entity before saving it, and it will be saved under this ID.