|
@@ -29,20 +29,21 @@ use Drupal\mymodule\Plugin\Field\FieldType\MyFieldComputed;
|
|
* @param array $base_field_definitions
|
|
* @param array $base_field_definitions
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
-// function materio_home_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
|
|
|
|
-function materio_home_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
|
|
|
|
|
|
+function materio_home_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
|
|
|
|
+// function materio_home_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
|
|
// $fields = array();
|
|
// $fields = array();
|
|
// if ($entity_type->id() == 'node' && $bundle === 'frontpage') {
|
|
// if ($entity_type->id() == 'node' && $bundle === 'frontpage') {
|
|
- if ($entity_type->id() == 'node') {
|
|
|
|
|
|
+ // \Drupal::logger('materio_home')->notice('bundle: '.$bundle);
|
|
|
|
+ if ($entity_type->id() == 'node' && $bundle == 'frontpage') {
|
|
$fields['computed_materials_reference'] = BaseFieldDefinition::create('entity_reference')
|
|
$fields['computed_materials_reference'] = BaseFieldDefinition::create('entity_reference')
|
|
->setName('computed_materials_reference')
|
|
->setName('computed_materials_reference')
|
|
->setLabel(t('Computed Materials References'))
|
|
->setLabel(t('Computed Materials References'))
|
|
->setDescription(t('Computed Materials References.'))
|
|
->setDescription(t('Computed Materials References.'))
|
|
// // The Entity Type this field belongs to.
|
|
// // The Entity Type this field belongs to.
|
|
- ->setSetting('target_type', 'node')
|
|
|
|
|
|
+ ->setTargetEntityTypeId($entity_type->id())
|
|
// // The Entity Type bundle this field belongs to.
|
|
// // The Entity Type bundle this field belongs to.
|
|
- ->setTargetBundle('frontpage')
|
|
|
|
- ->setTargetEntityTypeId('node')
|
|
|
|
|
|
+ ->setTargetBundle($bundle)
|
|
|
|
+ ->setSetting('target_type', 'node')
|
|
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
|
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
|
->setComputed(TRUE)
|
|
->setComputed(TRUE)
|
|
->setRevisionable(FALSE)
|
|
->setRevisionable(FALSE)
|
|
@@ -58,11 +59,11 @@ function materio_home_entity_base_field_info_alter(&$fields, EntityTypeInterface
|
|
->setName('computed_showrooms_reference')
|
|
->setName('computed_showrooms_reference')
|
|
->setLabel(t('Computed Showrooms References'))
|
|
->setLabel(t('Computed Showrooms References'))
|
|
->setDescription(t('Computed Showrooms References.'))
|
|
->setDescription(t('Computed Showrooms References.'))
|
|
- ->setSetting('target_type', 'taxonomy_term')
|
|
|
|
// // The Entity Type this field belongs to.
|
|
// // The Entity Type this field belongs to.
|
|
- ->setTargetEntityTypeId('node')
|
|
|
|
|
|
+ ->setTargetEntityTypeId($entity_type->id())
|
|
// // The Entity Type bundle this field belongs to.
|
|
// // The Entity Type bundle this field belongs to.
|
|
- ->setTargetBundle('frontpage')
|
|
|
|
|
|
+ ->setTargetBundle($bundle)
|
|
|
|
+ ->setSetting('target_type', 'taxonomy_term')
|
|
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
|
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
|
->setComputed(TRUE)
|
|
->setComputed(TRUE)
|
|
->setRevisionable(FALSE)
|
|
->setRevisionable(FALSE)
|
|
@@ -73,8 +74,29 @@ function materio_home_entity_base_field_info_alter(&$fields, EntityTypeInterface
|
|
'weight' => -5,
|
|
'weight' => -5,
|
|
])
|
|
])
|
|
->setClass(\Drupal\materio_home\Plugin\Field\FieldType\ComputedShowroomsReferences::class);
|
|
->setClass(\Drupal\materio_home\Plugin\Field\FieldType\ComputedShowroomsReferences::class);
|
|
|
|
+
|
|
|
|
+ $fields['computed_articles_reference'] = BaseFieldDefinition::create('entity_reference')
|
|
|
|
+ ->setName('computed_articles_reference')
|
|
|
|
+ ->setLabel(t('Computed Articles References'))
|
|
|
|
+ ->setDescription(t('Computed Articles References.'))
|
|
|
|
+ // // The Entity Type this field belongs to.
|
|
|
|
+ ->setTargetEntityTypeId($entity_type->id())
|
|
|
|
+ // // The Entity Type bundle this field belongs to.
|
|
|
|
+ ->setTargetBundle($bundle)
|
|
|
|
+ ->setSetting('target_type', 'node')
|
|
|
|
+ ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
|
|
|
|
+ ->setComputed(TRUE)
|
|
|
|
+ ->setRevisionable(FALSE)
|
|
|
|
+ ->setTranslatable(FALSE)
|
|
|
|
+ ->setDisplayConfigurable('view', TRUE)
|
|
|
|
+ ->setDisplayOptions('view', [
|
|
|
|
+ 'label' => 'hidden',
|
|
|
|
+ 'weight' => -5,
|
|
|
|
+ ])
|
|
|
|
+ ->setClass(\Drupal\materio_home\Plugin\Field\FieldType\ComputedArticlesReferences::class);
|
|
|
|
+
|
|
|
|
+ return $fields;
|
|
}
|
|
}
|
|
- return $fields;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// /**
|
|
// /**
|