flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

FEATURE: Allow usage of is*/has* accessors in EEL/Fusion directly

Open mhsdesign opened this issue 1 year ago • 0 comments

Is there a reason that fluids property access is slightly different than eels?

In fusion/eel i would also like to call ${fooo.isSomething} which calls the method isSomething() to be more descriptive than ${fooo.something} which feels more like a direct getter and will actually use the getter if defined.

That was brought to fluid as feature but never implemented in ObjectAccess directly: https://github.com/neos/flow-development-collection/pull/108

Implementing this would make the RenderingMode object in Neos better usable in php. To have speaking is* access in eel via renderingMode.isEdit we cheat our way around this by using public readonly properties: https://github.com/neos/neos-development-collection/blob/e3ff7a4a1f50b2a23c76071536d66506acfa6f8e/Neos.Neos/Classes/Domain/Model/RenderingMode.php#L32-L33

But i just noticed in php how odd it feels and looks to write

if ($renderingMode->isEdit) {
    // bla
}

instead of

if ($renderingMode->isEdit()) {
    // bla
}

so what are the odds of getting this through? Is this a simple win?

But i also just found out that code in the mentioned pr from 2015 doesnt exist anymore and is part of the default fluid accessor StandardVariableProvider:

                $isMethod = 'is' . $upperCasePropertyName;
                if (method_exists($subject, $isMethod)) {
                    $subject = $subject->$isMethod();
                    continue;
                }
                $hasMethod = 'has' . $upperCasePropertyName;
                if (method_exists($subject, $hasMethod)) {
                    $subject = $subject->$hasMethod();
                    continue;
                }

mhsdesign avatar Feb 06 '24 17:02 mhsdesign