Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nelson-ph/c30507761df286ac652f984f30d263c7 to your computer and use it in GitHub Desktop.
Save nelson-ph/c30507761df286ac652f984f30d263c7 to your computer and use it in GitHub Desktop.
Drupal 8 - Prevent Call to undefined method Drupal\\Core\\Field\\BaseFieldDefinition::getThirdPartySettings
Index: ./filefield_paths.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ./filefield_paths.module (date 1517934386000)
+++ ./filefield_paths.module (date 1517934386000)
@@ -344,13 +344,15 @@
if ($field instanceof FileFieldItemList) {
/** @var FieldConfig $definition */
$definition = $field->getFieldDefinition();
- $settings = $definition->getThirdPartySettings('filefield_paths');
- if (isset($settings['enabled']) && $settings['enabled']) {
- // Invoke hook_filefield_paths_process_file().
- foreach (\Drupal::moduleHandler()
- ->getImplementations('filefield_paths_process_file') as $module) {
- if (function_exists($function = "{$module}_filefield_paths_process_file")) {
- $function($entity, $field, $settings);
+ if(method_exists($definition, 'getThirdPartySettings')){
+ $settings = $definition->getThirdPartySettings('filefield_paths');
+ if (isset($settings['enabled']) && $settings['enabled']) {
+ // Invoke hook_filefield_paths_process_file().
+ foreach (\Drupal::moduleHandler()
+ ->getImplementations('filefield_paths_process_file') as $module) {
+ if (function_exists($function = "{$module}_filefield_paths_process_file")) {
+ $function($entity, $field, $settings);
+ }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment