- Issue created by @joachim
- π«π·France andypost
Option 2 looks good.
And related issues still makes sense
- π¬π§United Kingdom joachim
> Drupal\Component\Attribute
Does that mean that the EntityType attribute class, for instance, would be \Drupal\Component\Attribute\EntityType, rather than \Drupal\Core\Attribute\EntityType? That seems a bit weird.
Also, \Drupal\Component\Foo are meant to be components which are reusable outside of Drupal. I don't think there's anything especially reusable about a bunch of attribute classes.
- π³πΏNew Zealand quietone
Correct me if I am wrong but this is setting a coding standard so should be in Coding Standards project.
- π¦πΉAustria drunken monkey Vienna, Austria
I definitely prefer the first option. Adding
Php
as a namespace component seems rather strange to me. Itβs all PHP, so why should this specific set of classes get an explicitPhp
namespace?If we consider the potential for confusion with other kinds of attributes as too great, I would go for
Drupal\Component\PhpAttribute Drupal\my_module\PhpAttribute
instead. We want to make clear that itβs a βPHP attributeβ, not a βPHPβ that is also an βAttributeβ. As I donβt think weβd ever put a class into the
Drupal\Component\Php
namespace, it shouldnβt be a separate namespace. - π¬π§United Kingdom catch
\Drupal\Component\Attribute\EntityType, rather than \Drupal\Core\Attribute\EntityType?
No I think it would be
Drupal\Core\Entity\Attribute\EntityType
orDrupal\Core\Entity\PhpAttribute\EntityType
For me,
Drupal\Core\Entity\Attribute\EntityType
is a lot neater and I don't think there'll be any confusing with HTML attributes for the specific implementations.I've updated the issue summary to change from Php\Attribute to PhpAttribute - that was a typo on my part..
@quietone I don't think this is a coding standards issue, it's just deciding on class naming/namespacing for new core code, so moving it back to the core queue.
- π¬π§United Kingdom joachim
> No I think it would be Drupal\Core\Entity\Attribute\EntityType or Drupal\Core\Entity\PhpAttribute\EntityType
Ah ok. That makes more sense! :)
Can I change the IS to make it clearer that "Drupal\Component\Attribute" means "Drupal\*COMPONENT*\Attribute"? It's confusing as it is because Drupal\Component is an actual real namespace.
- π¬π§United Kingdom catch
@joachim there is going to be some code in
Drupal\Component\Attribute
, so it's really both not either/or. - π«π·France andypost
Not sure we need to disturb
Drupal\Component
namespace at all of Attributes will be placed in related subsystems - π¬π§United Kingdom alexpott πͺπΊπ
I think option 1 is fine and I disagree that π Move Attribute classes under Drupal\Component Needs review is need for us to make this decision. I think it is okay that \Drupal\Core\Template\Attribute is not a PHP attribute. Twig blocks are not Drupal blocks. HTML entities are not Drupal entities. A Twig node is not a Drupal node.
And for the ultimate one... Drupal\Core\Condition !== \Drupal\Core\Config\Entity\Query\Condition !== \Drupal\Core\Database\Query\Condition
- π¬π§United Kingdom longwave UK
+1 for option 1 - I agree with everything @alexpott said, and Symfony has a similar pattern so to avoid adding a new Drupalism I think we should follow Symfony here.
- π¬π§United Kingdom joachim
Side note, don't want to detail - what would go under Drupal\Component\Attribute?
- π¬π§United Kingdom catch
@joachim see the MR on the parent issue, for example https://git.drupalcode.org/project/drupal/-/merge_requests/1576/diffs#25...
@alexpott, the original plan in π Move Attribute classes under Drupal\Component Needs review was to put that code in
Drupal\Component\Attribute
- i.e. literally the same namespace and directory as being proposed here. It's not just a naming issue but actual namespace conflicts.We don't need to do that issue first or anything, but we do need to decide in both issues based on what's happening in the other. The latest version there using
Drupal\Component\HtmlAttribute
so there's no conflict now and I think we're fine, but that's only because of this discussion happening. - π«π·France andypost
Plugins using
Drupal\Component\Plugin\Discovery
soAttributeClassDiscovery.php
fits there but if we need to use it for controllers it should live in "core" - π¬π§United Kingdom alexpott πͺπΊπ
I think I made a mistake in π Use PHP attributes instead of doctrine annotations Fixed - I don't think that should be create Drupal\Component\Attribute ... I think I made an Attribute component because I was copying the Annotation component. But looking at this more closely I think the Drupal\Component\Attribute in that issue should be Drupal\Component\Plugin\Attribute because that's what it is for. No I look at it, I think having a Drupal\Component\Attribute is odd - like what are the attributes for?!!? It's the same with Drupal\Component\Annotation - it looks generic but actually it is part of the plugin system.
- π¬π§United Kingdom catch
Added
Drupal\Component\Plugin\Attribute
as option #3 in the issue summary, that works for me. - π¬π§United Kingdom joachim
Option 3 doesn't cover everything -- other things which aren't plugins will need attributes too.
It should be:
- Drupal\[Component/Core]\COMPONENT\Attribute
- Drupal\MODULE\Attribute - π¬π§United Kingdom alexpott πͺπΊπ
@joachim yep - I've updated option 3 to be more explicit and use your text.
- π¬π§United Kingdom joachim
Shall we say this is RTBC? Consensus seems to be option 3.
- Status changed to Needs work
over 1 year ago 5:10pm 7 March 2023 - π¬π§United Kingdom longwave UK
@joachim I think you accidentally reverted option 3 from the IS? But otherwise I move my vote to option 3 and agree this is RTBC as there seems to be no support for the other options.
- Status changed to Active
over 1 year ago 5:34pm 7 March 2023 - Status changed to RTBC
over 1 year ago 5:34pm 7 March 2023 - Status changed to Fixed
over 1 year ago 12:11pm 8 March 2023 - π¬π§United Kingdom catch
π Use PHP attributes instead of doctrine annotations Fixed is already following this, and we've got consensus here, so let's close this one out. Definitely easier in its own spin-off issue!
Automatically closed - issue fixed for 2 weeks with no activity.