-
Notifications
You must be signed in to change notification settings - Fork 10
ISSUE-274: Report render array output error in Metadata Display preview #275
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
Conversation
|
@aksm is still still on the works? Need any help or discussing? |
|
@DiegoPino I had a question about error reporting that I can dig back up for our call tomorrow. |
…y used Twig vars and unused JSON keys.
| */ | ||
| function _format_strawberryfield_metadata_preview_error_handler($error_level, $message, $filename = NULL, $line = NULL, $context = NULL) { | ||
| _drupal_error_handler(E_WARNING, $message, $filename, $line, $context); | ||
| throw new ErrorException($message, $error_level, 0, $filename, $line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... smart!
| $variables = []; | ||
| foreach ($nodes as $node) { | ||
| if ($node instanceof \Twig_Node_Expression_Name) { | ||
| if ($node instanceof \Twig\Node\Expression\NameExpression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@very nice!
| * A list of used $variables by this template. | ||
| */ | ||
| private function getTwigVariableNames(ModuleNode $nodes): array { | ||
| private function getTwigVariableNames(ModuleNode|Node|BodyNode $nodes): array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh.. this is new to me! So cool. So 3 params in the docs but really a single multi type one in the function argument?
| * AJAX callback. | ||
| */ | ||
| public static function ajaxPreview($form, FormStateInterface $form_state) { | ||
| set_error_handler('_format_strawberryfield_metadata_preview_error_handler'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool
| ]; | ||
| } | ||
| restore_error_handler(); | ||
| restore_exception_handler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this!
DiegoPino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's work on the next step together. I have high dreams about an JS/Interactive JS driven JSON picker
Start on resolving #274 with refactor to the below to replace deprecated classes.
format_strawberryfield/src/Entity/MetadataDisplayEntity.php
Lines 435 to 459 in 2e5cc2a