clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_animal_type
name: 'Animal type'
vid: animal_type
description: 'A list of animal species/breeds.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Animal type vocabulary
description: Provides an Animal type vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_lab
name: Lab
vid: lab
description: 'A list of labs.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Lab vocabulary
description: Provides a Lab vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_log_category
name: 'Log category'
vid: log_category
description: 'A list of log categories.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
module:
- farm_log_category
- log
id: log_categorize_action
label: 'Categorize'
type: log
plugin: 'log_categorize_action'
configuration: { }

View File

@@ -0,0 +1,4 @@
# Schema for actions.
action.configuration.log_categorize_action:
type: action_configuration_default
label: 'Configuration for the log categorize action'

View File

@@ -0,0 +1,8 @@
name: Log categories vocabulary
description: Provides a Log categories vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy
- log:log

View File

@@ -0,0 +1,56 @@
<?php
/**
* @file
* Contains farm_log_category.module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_entity_base_field_info().
*/
function farm_log_category_entity_base_field_info(EntityTypeInterface $entity_type) {
// Add category base field to all log types.
$fields = [];
if ($entity_type->id() == 'log') {
$category_info = [
'type' => 'entity_reference',
'label' => t('Log category'),
'description' => t('Use this to organize your logs into categories for easier searching and filtering later.'),
'target_type' => 'taxonomy_term',
'target_bundle' => 'log_category',
'multiple' => TRUE,
'weight' => [
'view' => 80,
],
'form_display_options' => [
'type' => 'options_select',
'weight' => 10,
],
];
$fields['category'] = \Drupal::service('farm_field.factory')->baseFieldDefinition($category_info);
}
return $fields;
}
/**
* Implements hook_farm_ui_theme_region_items().
*/
function farm_log_category_farm_ui_theme_region_items(string $entity_type) {
// Define common asset, log, and plan region items on behalf of core modules.
switch ($entity_type) {
case 'log':
return [
'second' => [
'category',
],
];
default:
return [];
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* @file
* Update hooks for farm_log_category.module.
*/
use Symfony\Component\Yaml\Yaml;
/**
* Create log categorize action.
*/
function farm_log_category_post_update_create_log_categorize_action(&$sandbox = NULL) {
$action_id = 'log_categorize_action';
$config_path = \Drupal::service('extension.list.module')->getPath('farm_log_category') . "/config/optional/system.action.$action_id.yml";
$data = Yaml::parseFile($config_path);
\Drupal::configFactory()
->getEditable("system.action.$action_id")
->setData($data)
->save(TRUE);
}

View File

@@ -0,0 +1,6 @@
farm_log_category.log_categorize_action_form:
path: '/log/categorize'
defaults:
_form: Drupal\farm_log_category\Form\LogCategorizeActionForm
requirements:
_user_is_logged_in: 'TRUE'

View File

@@ -0,0 +1,243 @@
<?php
namespace Drupal\farm_log_category\Form;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\Checkboxes;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Provides a categorize log confirmation form.
*/
class LogCategorizeActionForm extends ConfirmFormBase {
/**
* The tempstore factory.
*
* @var \Drupal\Core\TempStore\SharedTempStore
*/
protected $tempStore;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $user;
/**
* The entity type.
*
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* The assets to create logs for.
*
* @var \Drupal\Core\Entity\EntityInterface[]
*/
protected $entities;
/**
* Constructs a LogCategorizeActionForm form object.
*
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
* The tempstore factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Session\AccountInterface $user
* The current user.
*/
public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $entity_type_manager, AccountInterface $user) {
$this->tempStore = $temp_store_factory->get('log_categorize_confirm');
$this->entityTypeManager = $entity_type_manager;
$this->user = $user;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('tempstore.private'),
$container->get('entity_type.manager'),
$container->get('current_user')
);
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'log_categorize_action_confirm_form';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->formatPlural(count($this->entities), 'Are you sure you want to categorize this @item?', 'Are you sure you want to categorize these @items?', [
'@item' => $this->entityType->getSingularLabel(),
'@items' => $this->entityType->getPluralLabel(),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
if ($this->entityType->hasLinkTemplate('collection')) {
return new Url('entity.' . $this->entityType->id() . '.collection');
}
else {
return new Url('<front>');
}
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return '';
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Categorize');
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$this->entityType = $this->entityTypeManager->getDefinition('log');
$this->entities = $this->tempStore->get($this->user->id());
if (empty($this->entityType) || empty($this->entities)) {
return new RedirectResponse($this->getCancelUrl()
->setAbsolute()
->toString());
}
// Load terms.
/** @var \Drupal\taxonomy\TermStorageInterface $term_storage */
$term_storage = $this->entityTypeManager->getSTorage('taxonomy_term');
$terms = $term_storage->loadTree('log_category', 0, NULL, TRUE);
// Filter to active terms.
$active_terms = array_filter($terms, function ($term) {
return (int) $term->get('status')->value;
});
// Build options with -- to represent hierarchies.
$options = [];
foreach ($active_terms as $term) {
// This approach taken from core TaxonomyIndexTid views filter plugin.
$label = str_repeat('-', $term->depth) . $term->label();
$options[$term->id()] = $label;
}
$form['category'] = [
'#type' => 'select',
'#title' => $this->t('Log category'),
'#description' => $this->t('Use this to organize your logs into categories for easier searching and filtering later.'),
'#options' => $options,
'#multiple' => TRUE,
];
$form['operation'] = [
'#type' => 'radios',
'#title' => $this->t('Append or replace'),
'#description' => $this->t('Select "Append" if you want to add a category, but keep the existing log categories. Select "Replace" if you want to replace the existing log categories with the ones specified above.'),
'#options' => [
'append' => $this->t('Append'),
'replace' => $this->t('Replace'),
],
'#default_value' => 'append',
'#required' => TRUE,
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Filter out entities the user doesn't have access to.
$inaccessible_entities = [];
$accessible_entities = [];
foreach ($this->entities as $entity) {
if (!$entity->access('update', $this->currentUser())) {
$inaccessible_entities[] = $entity;
continue;
}
$accessible_entities[] = $entity;
}
// Get submitted category IDs.
$submitted_category_ids = Checkboxes::getCheckedCheckboxes($form_state->getValue('category', []));
// Update categories on accessible entities.
$total_count = 0;
foreach ($accessible_entities as $entity) {
/** @var \Drupal\Core\Field\EntityReferenceFieldItemList $category_field */
if ($category_field = $entity->get('category')) {
// Save existing values if appending.
$existing_values = [];
if ($form_state->getValue('operation') === 'append') {
$existing_values = array_column($category_field->getValue(), 'target_id');
}
// Empty the field.
$category_field->setValue([]);
$new_values = array_unique(array_merge($existing_values, $submitted_category_ids));
foreach ($new_values as $parent_id) {
$category_field->appendItem($parent_id);
}
$entity->save();
$total_count++;
}
}
// Add warning message for inaccessible entities.
if (!empty($inaccessible_entities)) {
$inaccessible_count = count($inaccessible_entities);
$this->messenger()->addWarning($this->formatPlural($inaccessible_count, 'Could not categorize @count @item because you do not have the necessary permissions.', 'Could not categorize @count @items because you do not have the necessary permissions.', [
'@item' => $this->entityType->getSingularLabel(),
'@items' => $this->entityType->getPluralLabel(),
]));
}
// Add confirmation message.
if (!empty($total_count)) {
$this->messenger()->addStatus($this->formatPlural($total_count, 'Categorized @count @item.', 'Categorized @count @items.', [
'@item' => $this->entityType->getSingularLabel(),
'@items' => $this->entityType->getPluralLabel(),
]));
}
$this->tempStore->delete($this->currentUser()->id() . ':' . $this->entityType->id());
$form_state->setRedirectUrl($this->getCancelUrl());
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Drupal\farm_log_category\Plugin\Action;
use Drupal\Core\Action\Plugin\Action\EntityActionBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Redirects to a form to add categories to a log.
*
* @Action(
* id = "log_categorize_action",
* action_label = @Translation("Categorize log"),
* type = "log",
* confirm_form_route_name = "farm_log_category.log_categorize_action_form"
* )
*/
class LogCategorize extends EntityActionBase {
/**
* The tempstore object.
*
* @var \Drupal\Core\TempStore\SharedTempStore
*/
protected $tempStore;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* Constructs a new LogCategorize object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
* The tempstore factory.
* @param \Drupal\Core\Session\AccountInterface $current_user
* Current user.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) {
$this->currentUser = $current_user;
$this->tempStore = $temp_store_factory->get('log_categorize_confirm');
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager'),
$container->get('tempstore.private'),
$container->get('current_user')
);
}
/**
* {@inheritdoc}
*/
public function executeMultiple(array $entities) {
/** @var \Drupal\Core\Entity\EntityInterface[] $entities */
$this->tempStore->set($this->currentUser->id(), $entities);
}
/**
* {@inheritdoc}
*/
public function execute($object = NULL) {
$this->executeMultiple([$object]);
}
/**
* {@inheritdoc}
*/
public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = $object->get('category')->access('edit', $account, TRUE)
->andIf($object->access('update', $account, TRUE));
return $return_as_object ? $result : $result->isAllowed();
}
}

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_material_type
name: 'Material type'
vid: material_type
description: 'A list of material types.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Material types vocabulary
description: Provides a Material types vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,37 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.companions
- taxonomy.vocabulary.plant_type
enforced:
module:
- farm_plant_type
module:
- entity_reference_validators
third_party_settings:
entity_reference_validators:
circular_reference: false
circular_reference_deep: false
duplicate_reference: false
id: taxonomy_term.plant_type.companions
field_name: companions
entity_type: taxonomy_term
bundle: plant_type
label: Companions
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
plant_type: plant_type
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

View File

@@ -0,0 +1,31 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.crop_family
- taxonomy.vocabulary.crop_family
- taxonomy.vocabulary.plant_type
enforced:
module:
- farm_plant_type
id: taxonomy_term.plant_type.crop_family
field_name: crop_family
entity_type: taxonomy_term
bundle: plant_type
label: 'Crop family'
description: 'What crop family is this a member of?'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
crop_family: crop_family
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

View File

@@ -0,0 +1,25 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.harvest_days
- taxonomy.vocabulary.plant_type
enforced:
module:
- farm_plant_type
id: taxonomy_term.plant_type.harvest_days
field_name: harvest_days
entity_type: taxonomy_term
bundle: plant_type
label: 'Days of harvest'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
min: 1
max: null
prefix: ''
suffix: ' day| days'
field_type: integer

View File

@@ -0,0 +1,25 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.maturity_days
- taxonomy.vocabulary.plant_type
enforced:
module:
- farm_plant_type
id: taxonomy_term.plant_type.maturity_days
field_name: maturity_days
entity_type: taxonomy_term
bundle: plant_type
label: 'Days to maturity'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
min: 1
max: null
prefix: ''
suffix: ' day| days'
field_type: integer

View File

@@ -0,0 +1,21 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
module:
- taxonomy
id: taxonomy_term.companions
field_name: companions
entity_type: taxonomy_term
type: entity_reference
settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@@ -0,0 +1,21 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
module:
- taxonomy
id: taxonomy_term.crop_family
field_name: crop_family
entity_type: taxonomy_term
type: entity_reference
settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
module:
- taxonomy
id: taxonomy_term.harvest_days
field_name: harvest_days
entity_type: taxonomy_term
type: integer
settings:
unsigned: true
size: normal
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
module:
- taxonomy
id: taxonomy_term.maturity_days
field_name: maturity_days
entity_type: taxonomy_term
type: integer
settings:
unsigned: true
size: normal
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
name: 'Crop family'
vid: crop_family
description: 'A list of crop families.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_plant_type
name: 'Plant type'
vid: plant_type
description: 'A list of crops/varieties.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Plant type vocabulary
description: Provides an Plant type vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,101 @@
<?php
/**
* @file
* Contains farm_plant_type.module.
*/
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
/**
* Implements hook_entity_form_display_alter().
*/
function farm_plant_type_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context) {
if ($context['entity_type'] == 'taxonomy_term' && $context['bundle'] == 'plant_type' && $form_display->getMode() == 'default' && $form_display->isNew()) {
$form_display->setComponent('crop_family', [
'type' => 'entity_reference_autocomplete',
'settings' => [
'match_operator' => 'CONTAINS',
'match_limit' => 10,
'size' => 60,
'placeholder' => '',
],
'region' => 'content',
'weight' => 10,
]);
$form_display->setComponent('maturity_days', [
'type' => 'number',
'settings' => [
'placeholder' => '',
],
'region' => 'content',
'weight' => 20,
]);
$form_display->setComponent('harvest_days', [
'type' => 'number',
'settings' => [
'placeholder' => '',
],
'region' => 'content',
'weight' => 30,
]);
$form_display->setComponent('companions', [
'type' => 'entity_reference_autocomplete',
'settings' => [
'match_operator' => 'CONTAINS',
'match_limit' => 10,
'size' => 60,
'placeholder' => '',
],
'region' => 'content',
'weight' => 40,
]);
}
}
/**
* Implements hook_entity_view_display_alter().
*/
function farm_plant_type_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
if ($context['entity_type'] == 'taxonomy_term' && $context['bundle'] == 'plant_type' && $display->getMode() == 'full' && $display->isNew()) {
$display->setComponent('crop_family', [
'type' => 'entity_reference_label',
'label' => 'inline',
'settings' => [
'link' => TRUE,
],
'region' => 'content',
'weight' => 10,
]);
$display->setComponent('maturity_days', [
'type' => 'number_integer',
'label' => 'inline',
'settings' => [
'thousand_separator' => '',
'prefix_suffix' => TRUE,
],
'region' => 'content',
'weight' => 20,
]);
$display->setComponent('harvest_days', [
'type' => 'number_integer',
'label' => 'inline',
'settings' => [
'thousand_separator' => '',
'prefix_suffix' => TRUE,
],
'region' => 'content',
'weight' => 30,
]);
$display->setComponent('companions', [
'type' => 'entity_reference_label',
'label' => 'inline',
'settings' => [
'link' => TRUE,
],
'region' => 'content',
'weight' => 40,
]);
}
}

View File

@@ -0,0 +1,151 @@
<?php
/**
* @file
* Post update hooks for the farm_plant_type module.
*/
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Delete default form/view display config for plant type fields.
*/
function farm_plant_type_post_update_delete_display_config(&$sandbox) {
// We only do this if the farm_update module is enabled, under the assumption
// that farm_update would be keeping these configurations in a default state.
if (\Drupal::moduleHandler()->moduleExists('farm_update')) {
$form_display_config = EntityFormDisplay::load('taxonomy_term.plant_type.default');
$form_display_config->delete();
$view_display_config = EntityViewDisplay::load('taxonomy_term.plant_type.default');
$view_display_config->delete();
}
}
/**
* Set the minimum value of maturity_days and transplant_days to 1.
*/
function farm_plant_type_post_update_min_1_day(&$sandbox) {
// Set the min setting of both fields to 1.
$field_names = [
'maturity_days',
'transplant_days',
];
foreach ($field_names as $field_name) {
$field = FieldConfig::load('taxonomy_term.plant_type.' . $field_name);
if (!empty($field)) {
$field->setSetting('min', 1);
$field->save();
}
}
// Delete any zero values from the database.
$tables = [
'taxonomy_term__maturity_days' => 'maturity_days_value',
'taxonomy_term__transplant_days' => 'transplant_days_value',
'taxonomy_term_revision__maturity_days' => 'maturity_days_value',
'taxonomy_term_revision__transplant_days' => 'transplant_days_value',
];
foreach ($tables as $table => $column) {
\Drupal::database()
->query('DELETE FROM {' . $table . '} WHERE ' . $column . ' = 0');
}
}
/**
* Add harvest_days field to plant_type terms.
*/
function farm_plant_type_post_update_add_harvest_days(&$sandbox) {
$field_storage = FieldStorageConfig::create([
'id' => 'taxonomy_term.harvest_days',
'field_name' => 'harvest_days',
'entity_type' => 'taxonomy_term',
'type' => 'integer',
'settings' => [
'unsigned' => TRUE,
'size' => 'normal',
],
'module' => 'core',
'locked' => FALSE,
'cardinality' => 1,
'indexes' => [],
'persist_with_no_fields' => FALSE,
'custom_storage' => FALSE,
'dependencies' => [
'enforced' => [
'module' => [
'farm_plant_type',
],
],
'module' => [
'taxonomy',
],
],
]);
$field_storage->save();
$field = FieldConfig::create([
'id' => 'taxonomy_term.plant_type.harvest_days',
'field_name' => 'harvest_days',
'entity_type' => 'taxonomy_term',
'bundle' => 'plant_type',
'label' => 'Days of harvest',
'description' => '',
'required' => FALSE,
'default_value' => [],
'default_value_callback' => '',
'settings' => [
'min' => 1,
'max' => NULL,
'prefix' => '',
'suffix' => ' day| days',
],
'field_type' => 'integer',
'dependencies' => [
'enforced' => [
'module' => [
'farm_plant_type',
],
],
'module' => [
'taxonomy',
],
],
]);
$field->save();
}
/**
* Move transplant_days field to farm_transplant module.
*/
function farm_plant_type_post_update_move_transplant_days() {
// The transplant_days field was previously part of this module. It has moved
// to the farm_transplanting module, so that it is only made available in
// instances that deal with transplants. If there is transplant_days data in
// the database, but the farm_transplant module is not installed, we should
// install it so that module can be responsible for the data moving forward.
$data_count = \Drupal::database()->query('SELECT COUNT(*) FROM {taxonomy_term__transplant_days}')->fetchField();
if (!empty($data_count)) {
if (!\Drupal::service('module_handler')->moduleExists('farm_transplanting')) {
\Drupal::configFactory()->getEditable('field.field.taxonomy_term.plant_type.transplant_days')->delete();
\Drupal::configFactory()->getEditable('field.storage.taxonomy_term.transplant_days')->delete();
\Drupal::service('module_installer')->install(['farm_transplanting']);
}
}
// Otherwise, we can delete the transplant_days field.
// Using FieldConfig::load() and FieldStorageConfig::load() and their
// associated delete() methods will delete the config and database tables.
else {
$field = FieldConfig::load('taxonomy_term.plant_type.transplant_days');
if (!empty($field)) {
$field->delete();
}
$field_storage = FieldStorageConfig::load('taxonomy_term.transplant_days');
if (!empty($field_storage)) {
$field_storage->delete();
}
}
}

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_product_type
name: 'Product type'
vid: product_type
description: 'A list of product types.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Product type vocabulary
description: Provides an Product type vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_season
name: Season
vid: season
description: 'A list of seasons.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Seasons vocabulary
description: Provides a Seasons vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_test_method
name: 'Test method'
vid: test_method
description: 'A list of test methods.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Test method vocabulary
description: Provides a Test method vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy

View File

@@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_unit
name: Unit
vid: unit
description: 'A list of units for measurement purposes.'
weight: 0
new_revision: false

View File

@@ -0,0 +1,7 @@
name: Units vocabulary
description: Provides a Units vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^10
dependencies:
- drupal:taxonomy