Skip to content
Snippets Groups Projects
Commit 579a85aa authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Pierre Dureau
Browse files

Issue #3498456 by christian.wiedemann, grimreaper, pdureau: PHP warnings with computed fields

parent a4e5432d
No related branches found
No related tags found
1 merge request!324Issue #3498456 by christian.wiedemann, grimreaper, pdureau: [2.0.0-rc2] PHP...
Pipeline #402975 passed
......@@ -444,10 +444,19 @@ class FieldFormatterSource extends FieldValueSourceBase implements TrustedCallba
public function calculateDependencies() : array {
$dependencies = parent::calculateDependencies();
$configuration = $this->getConfiguration();
$fieldDefinition = $this->getFieldDefinition();
if (empty($configuration['settings']['type'])) {
return $dependencies;
}
$formatter = $this->createInstanceFormatter($configuration['settings']['type'], $this->getFieldDefinition());
$formatter = NULL;
try {
$formatter = $this->createInstanceFormatter($configuration['settings']['type'], $fieldDefinition);
}
catch (\Throwable $exception) {
// During install computeDependencies instance this plugin.
// This can lead to unexpected configuration states. We can ignore it.
}
if (!$formatter) {
return $dependencies;
}
......
......@@ -215,13 +215,19 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
* @throws \Drupal\Core\Render\Component\Exception\ComponentNotFoundException
*/
public function calculateComponentDependencies(?string $component_id = NULL, array $configuration = [], array $contexts = []) : array {
$component = $this->componentPluginManager->find($component_id ?? $configuration['component_id']);
$dependencies = [];
if ($this->componentPluginManager instanceof UiPatternsComponentPluginManager) {
SourcePluginBase::mergeConfigDependencies($dependencies, $this->componentPluginManager->calculateDependencies($component));
try {
$component = $this->componentPluginManager->find($component_id ?? $configuration['component_id']);
if ($this->componentPluginManager instanceof UiPatternsComponentPluginManager) {
SourcePluginBase::mergeConfigDependencies($dependencies, $this->componentPluginManager->calculateDependencies($component));
}
SourcePluginBase::mergeConfigDependencies($dependencies, $this->calculateComponentDependenciesProps($component, $configuration, $contexts));
SourcePluginBase::mergeConfigDependencies($dependencies, $this->calculateComponentDependenciesSlots($component, $configuration, $contexts));
}
catch (\Throwable $exception) {
// During install mergeConfigDependencies can lead to
// unexpected configuration states. We can ignore it.
}
SourcePluginBase::mergeConfigDependencies($dependencies, $this->calculateComponentDependenciesProps($component, $configuration, $contexts));
SourcePluginBase::mergeConfigDependencies($dependencies, $this->calculateComponentDependenciesSlots($component, $configuration, $contexts));
return $dependencies;
}
......
......@@ -412,6 +412,11 @@ abstract class EntityFieldSourceDeriverBase extends DeriverBase implements Conta
->setLabel((string) ($entity_type_fields_data["label"] ?? ""));
// Derive when bundle is unknown (in views for example)
foreach ($entity_type_fields_data["field_storages"] as $field_name => $field_storage_data) {
if (!isset($field_storage_data["label"])) {
// During site install $field_storage_data is not setup completed.
// Skip for now.
continue;
}
$field_name_context = (new ContextDefinition('string'))
->setRequired()
->setLabel("field_name")
......@@ -443,6 +448,7 @@ abstract class EntityFieldSourceDeriverBase extends DeriverBase implements Conta
->setLabel("Bundle")
->addConstraint('AllowedValues', array_merge($field_storage_data["bundles"] ?? [], [""]));
foreach ($field_storage_data["properties"] as $property_id => $property_data) {
$base_plugin_derivative = array_merge($base_plugin_definition, [
'label' => $property_data["label"],
'context_definitions' => [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment