Updated: Comment #0

Problem/Motivation

We've been replacing info hooks with either plugins or YAML, I thought it would be interesting to see how hook_element_info() would look in YAML.

Proposed resolution

Convert hook_element_info() to *.element_info.yml

Remaining tasks

N/A

User interface changes

N/A

API changes

hook_element_info() is removed, *.element_info.yml is used instead

CommentFileSizeAuthor
#1 element-info-2086311-1.patch38.86 KBtim.plunkett

Comments

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +API change
StatusFileSize
new38.86 KB
webchick’s picture

Hm. Not so sure about this, now that I look at it. #keys in YAML files are very strange. Maybe best to keep Drupalish code in Drupalish patterns (e.g. info hooks).

tim.plunkett’s picture

Agreed. Actually the worst part to me is this:

+++ b/core/modules/contextual/contextual.element_info.yml
@@ -0,0 +1,18 @@
+  '#attached':
+    library:
+      -
+        - contextual
+        - drupal.contextual-links

+++ b/core/modules/contextual/contextual.module
@@ -154,28 +154,6 @@ function contextual_library_info() {
-    '#attached' => array(
-      'library' => array(
-        array('contextual', 'drupal.contextual-links'),
-      ),
-    ),

So, won't fix? It was a worthwhile exercise, and now we have this issue to point to if someone else suggests it...

larowlan’s picture

These would make sense as real plugins if we had an API other than arrays, so that's definitely d9 territory

dawehner’s picture

One reason why this might be a bad idea in general: Forms are always defined in PHP, so people are really used to that, why should elements be special ...
Additional it could add quite of an overhead to parse each of these yml files on each request, in contrast to php which is basically instant.

tim.plunkett’s picture

Status: Needs review » Closed (won't fix)

Yep

tim.plunkett’s picture