diff --git a/farm.profile b/farm.profile index d6108de93..c2ca7347d 100644 --- a/farm.profile +++ b/farm.profile @@ -60,7 +60,8 @@ function farm_modules() { 'farm_import_csv' => t('CSV importer'), 'farm_export_kml' => t('KML exporter'), 'farm_import_kml' => t('KML asset importer'), - 'farm_comment' => t('Comments on assets/logs'), + 'farm_comment_asset' => t('Asset comments'), + 'farm_comment_log' => t('Log comments'), 'farm_map_mapbox' => t('Mapbox map layers: Satellite, Outdoors'), 'farm_api_default_consumer' => t('Default API Consumer'), 'farm_fieldkit' => t('Field Kit integration'), diff --git a/modules/core/comment/farm_comment.info.yml b/modules/core/comment/farm_comment.info.yml index 5f3579e6b..a9c5f35ad 100644 --- a/modules/core/comment/farm_comment.info.yml +++ b/modules/core/comment/farm_comment.info.yml @@ -5,5 +5,3 @@ package: farmOS core_version_requirement: ^9 dependencies: - drupal:comment - - farm:asset - - log:log diff --git a/modules/core/comment/farm_comment.module b/modules/core/comment/farm_comment.module index db00c2f7a..b1820a064 100644 --- a/modules/core/comment/farm_comment.module +++ b/modules/core/comment/farm_comment.module @@ -6,23 +6,8 @@ */ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\Core\Entity\EntityTypeInterface; use Drupal\entity\BundleFieldDefinition; -/** - * Implements hook_entity_base_field_info(). - */ -function farm_comment_entity_base_field_info(EntityTypeInterface $entity_type) { - $fields = []; - - // Add comment base field to assets and logs. - if (in_array($entity_type->id(), ['asset', 'log'])) { - $fields['comment'] = farm_comment_base_field_definition($entity_type->id()); - } - - return $fields; -} - /** * Helper function for generating a standard comment base field definition. * diff --git a/modules/core/comment/config/install/comment.type.asset_comment.yml b/modules/core/comment/modules/asset/config/install/comment.type.asset_comment.yml similarity index 84% rename from modules/core/comment/config/install/comment.type.asset_comment.yml rename to modules/core/comment/modules/asset/config/install/comment.type.asset_comment.yml index 97a2c072c..05bbc7270 100644 --- a/modules/core/comment/config/install/comment.type.asset_comment.yml +++ b/modules/core/comment/modules/asset/config/install/comment.type.asset_comment.yml @@ -3,7 +3,7 @@ status: true dependencies: enforced: module: - - farm_comment + - farm_comment_asset id: asset_comment label: 'Asset comment' target_entity_type_id: asset diff --git a/modules/core/comment/config/install/core.entity_form_display.comment.asset_comment.default.yml b/modules/core/comment/modules/asset/config/install/core.entity_form_display.comment.asset_comment.default.yml similarity index 95% rename from modules/core/comment/config/install/core.entity_form_display.comment.asset_comment.default.yml rename to modules/core/comment/modules/asset/config/install/core.entity_form_display.comment.asset_comment.default.yml index 0ebf62ffd..6103ce737 100644 --- a/modules/core/comment/config/install/core.entity_form_display.comment.asset_comment.default.yml +++ b/modules/core/comment/modules/asset/config/install/core.entity_form_display.comment.asset_comment.default.yml @@ -6,7 +6,7 @@ dependencies: - field.field.comment.asset_comment.comment_body enforced: module: - - farm_comment + - farm_comment_asset module: - text id: comment.asset_comment.default diff --git a/modules/core/comment/config/install/core.entity_view_display.comment.asset_comment.default.yml b/modules/core/comment/modules/asset/config/install/core.entity_view_display.comment.asset_comment.default.yml similarity index 95% rename from modules/core/comment/config/install/core.entity_view_display.comment.asset_comment.default.yml rename to modules/core/comment/modules/asset/config/install/core.entity_view_display.comment.asset_comment.default.yml index 2d4fd434e..59deb9596 100644 --- a/modules/core/comment/config/install/core.entity_view_display.comment.asset_comment.default.yml +++ b/modules/core/comment/modules/asset/config/install/core.entity_view_display.comment.asset_comment.default.yml @@ -6,7 +6,7 @@ dependencies: - field.field.comment.asset_comment.comment_body enforced: module: - - farm_comment + - farm_comment_asset module: - text id: comment.asset_comment.default diff --git a/modules/core/comment/config/install/field.field.comment.asset_comment.comment_body.yml b/modules/core/comment/modules/asset/config/install/field.field.comment.asset_comment.comment_body.yml similarity index 94% rename from modules/core/comment/config/install/field.field.comment.asset_comment.comment_body.yml rename to modules/core/comment/modules/asset/config/install/field.field.comment.asset_comment.comment_body.yml index d4ec34a44..1d012096d 100644 --- a/modules/core/comment/config/install/field.field.comment.asset_comment.comment_body.yml +++ b/modules/core/comment/modules/asset/config/install/field.field.comment.asset_comment.comment_body.yml @@ -6,7 +6,7 @@ dependencies: - field.storage.comment.comment_body enforced: module: - - farm_comment + - farm_comment_asset module: - text id: comment.asset_comment.comment_body diff --git a/modules/core/comment/modules/asset/farm_comment_asset.info.yml b/modules/core/comment/modules/asset/farm_comment_asset.info.yml new file mode 100644 index 000000000..4e540b418 --- /dev/null +++ b/modules/core/comment/modules/asset/farm_comment_asset.info.yml @@ -0,0 +1,8 @@ +name: Asset comments +description: Enables comments on farmOS assets. +type: module +package: farmOS +core_version_requirement: ^9 +dependencies: + - farm:asset + - farm:farm_comment diff --git a/modules/core/comment/modules/asset/farm_comment_asset.module b/modules/core/comment/modules/asset/farm_comment_asset.module new file mode 100644 index 000000000..9d0a9ff9b --- /dev/null +++ b/modules/core/comment/modules/asset/farm_comment_asset.module @@ -0,0 +1,22 @@ +id() == 'asset') { + $fields['comment'] = farm_comment_base_field_definition('asset'); + } + + return $fields; +} diff --git a/modules/core/comment/config/install/comment.type.log_comment.yml b/modules/core/comment/modules/log/config/install/comment.type.log_comment.yml similarity index 85% rename from modules/core/comment/config/install/comment.type.log_comment.yml rename to modules/core/comment/modules/log/config/install/comment.type.log_comment.yml index 5deeff519..1ea70a5ce 100644 --- a/modules/core/comment/config/install/comment.type.log_comment.yml +++ b/modules/core/comment/modules/log/config/install/comment.type.log_comment.yml @@ -3,7 +3,7 @@ status: true dependencies: enforced: module: - - farm_comment + - farm_comment_log id: log_comment label: 'Log comment' target_entity_type_id: log diff --git a/modules/core/comment/config/install/core.entity_form_display.comment.log_comment.default.yml b/modules/core/comment/modules/log/config/install/core.entity_form_display.comment.log_comment.default.yml similarity index 95% rename from modules/core/comment/config/install/core.entity_form_display.comment.log_comment.default.yml rename to modules/core/comment/modules/log/config/install/core.entity_form_display.comment.log_comment.default.yml index bd9006027..b498e49a3 100644 --- a/modules/core/comment/config/install/core.entity_form_display.comment.log_comment.default.yml +++ b/modules/core/comment/modules/log/config/install/core.entity_form_display.comment.log_comment.default.yml @@ -6,7 +6,7 @@ dependencies: - field.field.comment.log_comment.comment_body enforced: module: - - farm_comment + - farm_comment_log module: - text id: comment.log_comment.default diff --git a/modules/core/comment/config/install/core.entity_view_display.comment.log_comment.default.yml b/modules/core/comment/modules/log/config/install/core.entity_view_display.comment.log_comment.default.yml similarity index 95% rename from modules/core/comment/config/install/core.entity_view_display.comment.log_comment.default.yml rename to modules/core/comment/modules/log/config/install/core.entity_view_display.comment.log_comment.default.yml index 2b7f1bc4c..8c6fe9bd7 100644 --- a/modules/core/comment/config/install/core.entity_view_display.comment.log_comment.default.yml +++ b/modules/core/comment/modules/log/config/install/core.entity_view_display.comment.log_comment.default.yml @@ -6,7 +6,7 @@ dependencies: - field.field.comment.log_comment.comment_body enforced: module: - - farm_comment + - farm_comment_log module: - text id: comment.log_comment.default diff --git a/modules/core/comment/config/install/field.field.comment.log_comment.comment_body.yml b/modules/core/comment/modules/log/config/install/field.field.comment.log_comment.comment_body.yml similarity index 94% rename from modules/core/comment/config/install/field.field.comment.log_comment.comment_body.yml rename to modules/core/comment/modules/log/config/install/field.field.comment.log_comment.comment_body.yml index 6cc3ce113..8930757ea 100644 --- a/modules/core/comment/config/install/field.field.comment.log_comment.comment_body.yml +++ b/modules/core/comment/modules/log/config/install/field.field.comment.log_comment.comment_body.yml @@ -6,7 +6,7 @@ dependencies: - field.storage.comment.comment_body enforced: module: - - farm_comment + - farm_comment_log module: - text id: comment.log_comment.comment_body diff --git a/modules/core/comment/modules/log/farm_comment_log.info.yml b/modules/core/comment/modules/log/farm_comment_log.info.yml new file mode 100644 index 000000000..27d6f71b3 --- /dev/null +++ b/modules/core/comment/modules/log/farm_comment_log.info.yml @@ -0,0 +1,8 @@ +name: Log comments +description: Enables comments on farmOS logs. +type: module +package: farmOS +core_version_requirement: ^9 +dependencies: + - farm:farm_comment + - log:log diff --git a/modules/core/comment/modules/log/farm_comment_log.module b/modules/core/comment/modules/log/farm_comment_log.module new file mode 100644 index 000000000..853cf9823 --- /dev/null +++ b/modules/core/comment/modules/log/farm_comment_log.module @@ -0,0 +1,22 @@ +id() == 'log') { + $fields['comment'] = farm_comment_base_field_definition('log'); + } + + return $fields; +}