Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageNotifierBase: restricts rendered fields to user/cck fields only #250

Open
OnkelTem opened this issue Mar 27, 2019 · 1 comment
Open

Comments

@OnkelTem
Copy link

I extended Message entity with a base field which I use to store the output.
Then I pass it in 'rendered fields' array of the notifier options.
And it doesn't work in \Drupal\message_notify\Plugin\Notifier\MessageNotifierBase::postSend because it expects the field must be a cck-one which is not the case in my situation.
Particularly this check breaks everything:

if (!$field = $this->entityTypeManager->getStorage('field_config')->load('message.' . $this->message->bundle() . '.' . $field_name)) {
    throw new MessageNotifyException('Field "' . $field_name . '"" does not exist.');
}

I propose replacing this with the basic: $this->message->hasField($field_name) and not bothering with deducing the nature of the field provided.

@OnkelTem
Copy link
Author

OnkelTem commented Mar 27, 2019

This is against 8.x-1.0-beta1:

diff --git a/src/Plugin/Notifier/MessageNotifierBase.php b/src/Plugin/Notifier/MessageNotifierBase.php
index 7b2682a..bb68917 100644
--- a/src/Plugin/Notifier/MessageNotifierBase.php
+++ b/src/Plugin/Notifier/MessageNotifierBase.php
@@ -137,8 +137,7 @@ abstract class MessageNotifierBase extends PluginBase implements MessageNotifier
         }
         $field_name = $this->configuration['rendered fields'][$view_mode];
 
-        // @todo Inject the content_type.manager if this check is needed.
-        if (!$field = $this->entityTypeManager->getStorage('field_config')->load('message.' . $this->message->bundle() . '.' . $field_name)) {
+        if (!$this->message->hasField($field_name)) {
           throw new MessageNotifyException('Field "' . $field_name . '"" does not exist.');
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant