2 Commits

20 changed files with 867 additions and 1051 deletions

View File

@ -8,7 +8,7 @@ id: node.materiau.title
field_name: title
entity_type: node
bundle: materiau
label: Name
label: Title
description: ''
required: true
translatable: false

View File

@ -32,6 +32,7 @@ third_party_settings:
- group_contents
- group_media
- group_taxonomy
- group_internal
parent_name: ''
weight: 0
format_type: tabs
@ -92,12 +93,12 @@ third_party_settings:
group_internal:
children:
- langcode
- field_date
- translation
- field_workflow
- field_migration
- field_memo
parent_name: ''
weight: 1
parent_name: group_htabs
weight: 13
format_type: tab
format_settings:
id: ''
@ -122,7 +123,7 @@ content:
third_party_settings: { }
region: content
field_date:
weight: 3
weight: 26
settings: { }
third_party_settings: { }
type: daterange_default

View File

@ -22,6 +22,7 @@ third_party_settings:
children:
- group_contents
- group_info
- group_internal
parent_name: ''
weight: 1
format_type: tabs
@ -54,8 +55,8 @@ third_party_settings:
- translation
- field_workflow
- field_migration
parent_name: ''
weight: 2
parent_name: group_tabs
weight: 22
format_type: tab
format_settings:
id: ''
@ -108,7 +109,8 @@ content:
region: content
field_public_address:
weight: 5
settings: { }
settings:
default_country: null
third_party_settings: { }
type: address_default
region: content

View File

@ -11,7 +11,7 @@ id: node.materiau.field_famille
field_name: field_famille
entity_type: node
bundle: materiau
label: Family
label: Famille
description: ''
required: true
translatable: false

View File

@ -16,10 +16,12 @@ translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: views
handler: 'default:node'
handler_settings:
view:
view_name: entity_references
display_name: entity_reference_1
arguments: { }
target_bundles:
materiau: materiau
sort:
field: _none
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

View File

@ -3,7 +3,7 @@ langcode: en
status: true
dependencies: { }
name: card_medium
label: 'card-medium (210x295)'
label: card-medium
effects:
34e936a0-1fee-4327-9553-b4f48bde14e6:
uuid: 34e936a0-1fee-4327-9553-b4f48bde14e6

View File

@ -1,15 +0,0 @@
uuid: 7b14e7ed-c822-49e2-9dfe-2bd07f535cb0
langcode: en
status: true
dependencies: { }
name: card_small
label: 'card-small (100x140)'
effects:
b36b5a37-6235-40e1-aef1-54fe4244ace6:
uuid: b36b5a37-6235-40e1-aef1-54fe4244ace6
id: image_scale_and_crop
weight: 1
data:
width: 100
height: 140
anchor: center-center

View File

@ -15,4 +15,4 @@ id: node.materiau
target_entity_type_id: node
target_bundle: materiau
default_langcode: site_default
language_alterable: false
language_alterable: true

View File

@ -13,5 +13,5 @@ type: materiau
description: ''
help: ''
new_revision: false
preview_mode: 0
preview_mode: 1
display_submitted: false

View File

@ -250,6 +250,7 @@ processor_settings:
solr_date_range:
weights:
preprocess_index: 0
term_delta: { }
tracker_settings:
default:
indexing_order: fifo

File diff suppressed because it is too large Load Diff

View File

@ -1233,7 +1233,7 @@ display:
group_items: { }
plugin_id: string
sorts: { }
title: Taxonomy
title: Tags
header:
result:
id: result
@ -3765,7 +3765,6 @@ display:
fields: false
filters: false
filter_groups: false
title: false
row:
type: fields
options: { }
@ -4578,7 +4577,6 @@ display:
weight: 0
context: '0'
menu_name: main
title: Thesaurus
cache_metadata:
max-age: 0
contexts:
@ -4685,7 +4683,6 @@ display:
fields: false
filters: false
filter_groups: false
title: false
row:
type: fields
options: { }
@ -5498,7 +5495,6 @@ display:
weight: 0
context: '0'
menu_name: main
title: Tags
cache_metadata:
max-age: 0
contexts:

View File

@ -1,417 +0,0 @@
uuid: 3555fe38-1079-44a4-b09f-9573151b3080
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_materiau_images
- field.storage.node.field_reference
- image.style.card_small
- node.type.materiau
module:
- computed_field
- entity_reference_revisions
- image
- node
- user
id: entity_references
label: 'Entity references'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: mini
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous:
next:
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
field_materiau_images:
id: field_materiau_images
table: node__field_materiau_images
field: field_materiau_images
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: image
settings:
image_style: card_small
image_link: ''
group_column: ''
group_columns: { }
group_rows: true
delta_limit: 1
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
plugin_id: field
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: false
ellipsis: false
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: node
entity_field: title
plugin_id: field
field_reference:
id: field_reference
table: node__field_reference
field: field_reference
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: computed_string
settings:
sanitized: 1
cache_unit: '-1'
cache_duration: '1'
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
plugin_id: field
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags:
- 'config:field.storage.node.field_materiau_images'
- 'config:field.storage.node.field_reference'
entity_reference_1:
display_plugin: entity_reference
id: entity_reference_1
display_title: 'Entity Reference materials'
position: 1
display_options:
display_extenders:
views_ef_fieldset: { }
style:
type: entity_reference
options:
search_fields:
title: title
field_reference: field_reference
filters:
status:
id: status
table: node_field_data
field: status
relationship: none
group_type: group
admin_label: ''
operator: '='
value: '1'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: boolean
entity_type: node
entity_field: status
type:
id: type
table: node_field_data
field: type
value:
materiau: materiau
entity_type: node
entity_field: type
plugin_id: bundle
defaults:
filters: false
filter_groups: false
filter_groups:
operator: AND
groups:
1: AND
display_description: ''
row:
type: entity_reference_revisions
options:
default_field_elements: true
inline:
field_materiau_images: field_materiau_images
title: title
field_reference: field_reference
separator: '-'
hide_empty: false
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags:
- 'config:field.storage.node.field_materiau_images'
- 'config:field.storage.node.field_reference'

View File

@ -11,7 +11,7 @@ module: workflow
from_sid: workflow_creation
to_sid: workflow_imported
roles:
workflow_author: '0'
anonymous: '0'
workflow_author: workflow_author
anonymous: anonymous
admin: '0'
root: '0'

View File

@ -21,7 +21,7 @@ editors_menus.company_add:
title: 'Add Companie'
appears_on:
- view.admin_taxo.page_1
editors_menus.showroom_add:
route_name: entity.taxonomy_term.add_form
route_parameters:
@ -29,22 +29,6 @@ editors_menus.showroom_add:
title: 'Add Showroom'
appears_on:
- view.admin_taxo.page_2
editors_menus.thesaurus_add:
route_name: entity.taxonomy_term.add_form
route_parameters:
taxonomy_vocabulary: 'thesaurus'
title: 'Add Thesaurus'
appears_on:
- view.admin_taxo.page_3
editors_menus.tag_add:
route_name: entity.taxonomy_term.add_form
route_parameters:
taxonomy_vocabulary: 'tags'
title: 'Add Tag'
appears_on:
- view.admin_taxo.page_4
editors_menus.user_add:
route_name: user.admin_create

View File

@ -61,16 +61,7 @@ function computed_field_field_reference_compute($entity_type_manager, $entity, $
*/
function materio_id_form_node_materiau_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// dsm($form_id);
// ksm($form);
$node = $form_state->getFormObject()->getEntity();
// lock the family filed if already filled
if(isset($form['field_famille']) && $family = $node->field_famille->value){
// dsm($family);
$form['field_famille']['widget']['#disabled'] = true;
}
// adding reference to the form title
$ref = $node->field_reference->value;
// dsm($ref);
if($ref != ''){

View File

@ -0,0 +1,27 @@
<?php
namespace Drupal\materio_sapi\Plugin\search_api\processor\Property;
use Drupal\Core\Entity\TypedData\EntityDataDefinition;
use Drupal\search_api\Processor\ProcessorPropertyInterface;
/**
* Provides a definition for a processor property that contains an entity.
*/
class TermDeltaEntityProcessorProperty extends EntityDataDefinition implements ProcessorPropertyInterface {
/**
* {@inheritdoc}
*/
public function getProcessorId() {
return $this->definition['processor_id'];
}
/**
* {@inheritdoc}
*/
public function isHidden() {
return !empty($this->definition['hidden']);
}
}

View File

@ -0,0 +1,430 @@
<?php
namespace Drupal\materio_sapi\Plugin\search_api\processor;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityFieldManager;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\EntityProcessorProperty;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\SearchApiException;
use Drupal\search_api\Utility\Utility;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Allows indexing of reverse entity references.
*
* @SearchApiProcessor(
* id = "term_delta",
* label = @Translation("Term Delta"),
* description = @Translation("Allow to boost term reference field value regarding delta."),
* stages = {
* "add_properties" = 0,
* },
* )
*/
class TermDelta extends ProcessorPluginBase {
/**
* Static cache for all entity references.
*
* @var array[][]|null
*
* @see \Drupal\search_api\Plugin\search_api\processor\ReverseEntityReferences::getEntityReferences()
*/
protected $references;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|null
*/
protected $entityTypeManager;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManager|null
*/
protected $entityFieldManager;
/**
* The entity type bundle info.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null
*/
protected $entityTypeBundleInfo;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface|null
*/
protected $languageManager;
/**
* The cache.
*
* @var \Drupal\Core\Cache\CacheBackendInterface|null
*/
protected $cache;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
/** @var static $processor */
$processor = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$processor->setEntityTypeManager($container->get('entity_type.manager'));
$processor->setEntityFieldManager($container->get('entity_field.manager'));
$processor->setEntityTypeBundleInfo($container->get('entity_type.bundle.info'));
$processor->setLanguageManager($container->get('language_manager'));
$processor->setCache($container->get('cache.default'));
return $processor;
}
/**
* Retrieves the entity type manager.
*
* @return \Drupal\Core\Entity\EntityTypeManagerInterface
* The entity type manager.
*/
public function getEntityTypeManager() {
return $this->entityTypeManager ?: \Drupal::entityTypeManager();
}
/**
* Sets the entity type manager.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The new entity type manager.
*
* @return $this
*/
public function setEntityTypeManager(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
return $this;
}
/**
* Retrieves the entity field manager.
*
* @return \Drupal\Core\Entity\EntityFieldManager
* The entity field manager.
*/
public function getEntityFieldManager() {
return $this->entityFieldManager ?: \Drupal::service('entity_field.manager');
}
/**
* Sets the entity field manager.
*
* @param \Drupal\Core\Entity\EntityFieldManager $entity_field_manager
* The new entity field manager.
*
* @return $this
*/
public function setEntityFieldManager(EntityFieldManager $entity_field_manager) {
$this->entityFieldManager = $entity_field_manager;
return $this;
}
/**
* Retrieves the entity type bundle info.
*
* @return \Drupal\Core\Entity\EntityTypeBundleInfoInterface
* The entity type bundle info.
*/
public function getEntityTypeBundleInfo() {
return $this->entityTypeBundleInfo ?: \Drupal::service('entity_type.bundle.info');
}
/**
* Sets the entity type bundle info.
*
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The new entity type bundle info.
*
* @return $this
*/
public function setEntityTypeBundleInfo(EntityTypeBundleInfoInterface $entity_type_bundle_info) {
$this->entityTypeBundleInfo = $entity_type_bundle_info;
return $this;
}
/**
* Retrieves the language manager.
*
* @return \Drupal\Core\Language\LanguageManagerInterface
* The language manager.
*/
public function getLanguageManager() {
return $this->languageManager ?: \Drupal::service('language_manager');
}
/**
* Sets the language manager.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The new language manager.
*
* @return $this
*/
public function setLanguageManager(LanguageManagerInterface $language_manager) {
$this->languageManager = $language_manager;
return $this;
}
/**
* Retrieves the cache.
*
* @return \Drupal\Core\Cache\CacheBackendInterface
* The cache.
*/
public function getCache() {
return $this->cache ?: \Drupal::service('cache.default');
}
/**
* Sets the cache.
*
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The new cache.
*
* @return $this
*/
public function setCache(CacheBackendInterface $cache) {
$this->cache = $cache;
return $this;
}
/**
* {@inheritdoc}
*/
public static function supportsIndex(IndexInterface $index) {
foreach ($index->getDatasources() as $datasource) {
if ($datasource->getEntityTypeId()) {
return TRUE;
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
// ksm($datasource);
$properties = [];
if (!$datasource || !$datasource->getEntityTypeId()) {
return $properties;
}
$references = $this->getEntityReferences();
// ksm($references);
// $entity_type_id = $datasource->getEntityTypeId();
// dsm($entity_type_id);
if (isset($references['taxonomy_term'])) {
foreach ($references['taxonomy_term'] as $key => $reference) {
$entity_type_id = $reference['entity_type'];
try {
$entity_type = $this->getEntityTypeManager()
->getDefinition($entity_type_id);
}
catch (PluginNotFoundException $e) {
continue;
}
// ksm($entity_type);
for ($delta=0; $delta < 5; $delta++) {
$args = [
'@delta' => $delta,
'@entity_type' => $entity_type->getLabel(),
'@property' => $reference['label'],
];
$definition = [
'label' => $this->t('@property [@delta] on @entity_type', $args),
// 'description' => $this->t("All %entity_type entities that reference this item via the %property field."),
'description' => $this->t("Term Delta [@delta] from field @property on @entity_type.", $args),
'type' => "entity:taxonomy_term",
'processor_id' => $this->getPluginId(),
// We can't really know whether this will end up being multi-valued, so
// we err on the side of caution.
'is_list' => TRUE,
];
$property = new EntityProcessorProperty($definition);
$property->setEntityTypeId('taxonomy_term');
$properties["materio_sapi_term_delta__{$entity_type_id}__{$reference['label']}__{$delta}"] = $property;
// code...
}
}
}
return $properties;
}
/**
* {@inheritdoc}
*/
public function addFieldValues(ItemInterface $item) {
// get the original indexed entity
try {
$entity = $item->getOriginalObject()->getValue();
}
catch (SearchApiException $e) {
return;
}
if (!($entity instanceof EntityInterface)) {
return;
}
// get the original
$entity_type_id = $entity->getEntityTypeId();
$entity_id = $entity->id();
$langcode = $entity->language()->getId();
$datasource_id = $item->getDatasourceId();
/** @var \Drupal\search_api\Item\FieldInterface[][][] $to_extract */
$to_extract = [];
$prefix = 'materio_sapi_term_delta__';
$prefix_length = strlen($prefix);
foreach ($item->getFields() as $field) {
$property_path = $field->getPropertyPath();
list($direct, $nested) = Utility::splitPropertyPath($property_path, FALSE);
if ($field->getDatasourceId() === $datasource_id
&& substr($direct, 0, $prefix_length) === $prefix) {
$property_name = substr($direct, $prefix_length);
$to_extract[$property_name][$nested][] = $field;
}
}
// ksm($to_extract);
$references = $this->getEntityReferences();
foreach ($to_extract as $property_name => $fields_to_extract) {
if (!isset($references[$entity_type_id][$property_name])) {
continue;
}
$property_info = $references[$entity_type_id][$property_name];
try {
$storage = $this->getEntityTypeManager()
->getStorage($property_info['entity_type']);
}
// @todo Replace with multi-catch once we depend on PHP 7.1+.
catch (InvalidPluginDefinitionException $e) {
continue;
}
catch (PluginNotFoundException $e) {
continue;
}
$entity_ids = $storage->getQuery()
->accessCheck(FALSE)
->condition($property_info['property'], $entity_id)
->execute();
$entities = $storage->loadMultiple($entity_ids);
if (!$entities) {
continue;
}
// This is a pretty hack-y work-around to make property extraction work for
// Views fields, too. In general, adding entities as field values is a
// pretty bad idea, so this might blow up in some use cases. Just do it for
// now and hope for the best.
if (isset($fields_to_extract[''])) {
foreach ($fields_to_extract[''] as $field) {
$field->setValues(array_values($entities));
}
unset($fields_to_extract['']);
}
foreach ($entities as $referencing_entity) {
$typed_data = $referencing_entity->getTypedData();
$this->getFieldsHelper()
->extractFields($typed_data, $fields_to_extract, $langcode);
}
}
}
/**
* Collects all entity references.
*
* @return array[][]
* An associative array of entity reference information keyed by the
* referenced entity type's ID and a custom identifier for the property
* (consisting of referencing entity type and property name), with values
* being associative arrays with the following keys:
* - label: The property label.
* - entity_type: The referencing entity type.
* - property: The property name.
*/
public function getEntityReferences() {
if ($this->references !== NULL) {
return $this->references;
}
// Property labels differ by language, so we need to vary the cache
// according to the current language.
$langcode = $this->getLanguageManager()->getCurrentLanguage()->getId();
$cid = "search_api:term_delta:$langcode";
$cache = $this->getCache()->get($cid);
if (isset($cache->data)) {
$this->references = $cache->data;
}
else {
$this->references = [];
$entity_types = $this->getEntityTypeManager()->getDefinitions();
$field_manager = $this->getEntityFieldManager();
$entity_type_bundle_info = $this->getEntityTypeBundleInfo();
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!($entity_type instanceof ContentEntityTypeInterface)) {
continue;
}
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $properties */
$properties = $field_manager->getBaseFieldDefinitions($entity_type_id);
$bundles = $entity_type_bundle_info->getBundleInfo($entity_type_id);
foreach ($bundles as $bundle => $info) {
$properties += $field_manager->getFieldDefinitions($entity_type_id, $bundle);
}
foreach ($properties as $name => $property) {
if ($property->getType() !== 'entity_reference') {
continue;
}
$settings = $property->getSettings();
if (empty($settings['target_type'])) {
continue;
}
$this->references[$settings['target_type']]["{$entity_type_id}__$name"] = [
'label' => $property->getLabel(),
'entity_type' => $entity_type_id,
'property' => $name,
];
}
}
$tags = [
'entity_types',
'entity_bundles',
'entity_field_info',
];
$this->getCache()->set($cid, $this->references, Cache::PERMANENT, $tags);
}
return $this->references;
}
}

View File

@ -1,65 +0,0 @@
<?php
/**
* @file
* Functions to support theming in the Seven theme.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
// function matminimal_preprocess_html(&$variables) {
// // If on a node add or edit page, add a node-layout class.
// $path_args = explode('/', \Drupal::request()->getPathInfo());
// if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
// foreach ($suggestions as $suggestion) {
// // dsm($suggestion);
// preg_match('/taxonomy-manage-[^-]+-add$/', $suggestion, $matches);
// // ksm($matches);
// if ($suggestion === 'page--taxonomy-term-edit' || isset($matches)) {
// $variables['attributes']['class'][] = 'node-form-layout';
// }
// }
// }
// }
// function matminimal_form_alter(&$form, FormStateInterface $form_state, $form_id){
// // dsm($form_id);
// // create a colomuned term form (not working yet)
// if(in_array($form_id, ['taxonomy_term_company_form', 'taxonomy_term_showroom_form'])){
// // ksm($form);
// $form['#theme'] = ['term_edit_form'];
// $form['#attached']['library'][] = 'seven/node-form';
//
// $form['advanced']['#type'] = 'container';
// $form['meta']['#type'] = 'container';
// $form['meta']['#access'] = TRUE;
// $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
// $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
//
// $form['revision_information']['#type'] = 'container';
// $form['revision_information']['#group'] = 'meta';
// }
// }
/**
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
*
* Changes vertical tabs to container.
*/
function matminimal_form_node_form_alter(&$form, FormStateInterface $form_state) {
$form['#theme'] = ['node_edit_form'];
$form['#attached']['library'][] = 'seven/node-form';
$form['advanced']['#type'] = 'container';
$form['meta']['#type'] = 'container';
$form['meta']['#access'] = TRUE;
$form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
$form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}

View File

@ -1,33 +0,0 @@
{#
/**
* @file
* Theme override for a node edit form.
*
* Two column template for the node add/edit form.
*
* This template will be used when a node edit form specifies 'node_edit_form'
* as its #theme callback. Otherwise, by default, node add/edit forms will be
* themed by form.html.twig.
*
* Available variables:
* - form: The node add/edit form.
*
* @see seven_form_node_form_alter()
*/
#}
<div class="layout-node-form clearfix">
<div class="layout-region layout-region-node-main">
{{ form|without('advanced', 'footer', 'actions', 'group_internal') }}
</div>
<div class="layout-region layout-region-node-secondary">
{{ form.group_internal }}
{{ form.advanced }}
{{ form.actions }}
</div>
<div class="layout-region layout-region-node-footer">
<div class="layout-region-node-footer__content">
{{ form.footer }}
</div>
</div>
</div>