On 04/29/2016 11:54 PM, Pierre Joye wrote:
Hi Larry,
On Apr 30, 2016 6:48 AM, "Larry Garfield" <la...@garfieldtech.com> wrote:
Most of the examples that have been given so far are either trivial
boolean flags or data validation rules to be evaled. In practice, very
little of Drupal's use of annotations in Drupal 8 fit either category.
Rather, they're used primarily as, in essence, a serialized metadata object
describing a class, which is used for registering that class and
potentially others. I figured I'd give the proposed syntax a try with some
Drupal examples and see how well it fit.
Disclaimer: I'm sure someone will pipe up with "your use case is invalid
because you shouldn't be using annotations that way."
What I would like to say yes. Very very loudly. But I am not sure about
what is what or what defined what in your complex example
Do you have a link to the source file so I can make an informed reply
please?
Sure.
The block annotation is defined here:
http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Block/Annotation/Block.php
And the particular block plugin that I showed is here:
http://cgit.drupalcode.org/drupal/tree/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php
The annotation for a content entity is here:
http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php
And the Node class is here:
http://cgit.drupalcode.org/drupal/tree/core/modules/node/src/Entity/Node.php
Note that in both cases I omitted the base class definition and such to
focus on the annotation. Drupal does make excessive use of inheritance.
I have been vocal about this problem for some time, but it will take a
little while for enough people to experience the pain of poor design
choices for them to get on board with better ones. Nonetheless, an
annotation system in core should be informed by real-world usage, and
Drupal is now a very significant real-world usage.
Also note that because Drupal is so heavily configuration driven, many
many things must be more dynamic and abstracted than they would in any
bespoke system. That's why Drupal tends to over-do so many things; it's
necessary to achieve runtime-configuration-driven data modeling and
display business logic.
--Larry Garfield
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php