- Issue created by @larowlan
- π¦πΊAustralia dpi Perth, Australia
I mentally approved this, but was on holiday at the time.
-
Further ideas, aligning with other Attribute style features.
The attribute should be able to target classes or methods.
If its on the class, the constructor is chosen. Needs compiler time validation to ensure constructor is public.
If its on a method, use this instead. Same public check.
Otherwise further enforcement of only one method per class (throw exceptions if found on multiple?)
- π¦πΊAustralia dpi Perth, Australia
Implemented in library @ https://github.com/dpi/pinto/pull/16
- π¦πΊAustralia dpi Perth, Australia
Slots feature @ π Implement Slots Active
- π¦πΊAustralia dpi Perth, Australia
This issue was from β¨ Allow objects in theme definitions Active
- π¦πΊAustralia dpi Perth, Australia
Had some further thoughts about this,
I wonder if we could add a property attribute e.g #[Theme\Variable] and put that on constructor Params and have the theme hook variables inferred from a theme object
Right now all slots come from reflection. This requirement kind of matches the other part of slots that needs to be implemented, strict listings of slots instead of reflection: https://github.com/dpi/pinto/issues/20
I also wonder if the method that does the build could auto fill # keys from properties with attributes so if you don't need any logic these get passed through to the render array automatically
Maybe each slot can have a thing where Pinto can lift out a value from where a slot definition is on a promoted public property, so the build method doesnt need to fill the slot value. And the return value could become optional if all slots are derived from promoted properties.
- π¦πΊAustralia dpi Perth, Australia
Explicit slot definitions are now a thing, per β¨ Allow theme objects to define a list of slots instead of only by reflection Active
E.g:
#[Slots( slots: [ new Slot(name: SlotEnum::Slot1), new Slot(name: SlotEnum::Slot2, defaultValue: 3), ], )] final class SlotsObjectExplicitEnums {}
What remains is the promoted public property ideas.
- π¦πΊAustralia dpi Perth, Australia
This is what I imaging it would look like:
\Pinto\Attribute\ObjectType\Slots.
Add new
public bool $bindPromotedProperties = false,
param:When true, and when there is nothing in $slots, values of promoted properties will be set on the \Pinto\Slots\Build object provided to the builder (usually __invoke) AFTER the builder method has run, and only if the builder method did not already set a value for the slot.
This would effectively allow the builder method to be completely empty.
I think it might also be helpful for a new attribute that could be added to regular class public properties (not promoted properties), that slot values can similarly be derived from.
class MyObj { #[BindSlotTo[target: 'name_of_a_slot_OR_enumCase'] public $mySlot = 'Foo'; }
Is this what you had in mind?
Any better vocablary ~bind?
- Status changed to Fixed
about 2 months ago 10:09am 22 November 2024 Automatically closed - issue fixed for 2 weeks with no activity.