Project

General

Profile

Actions

Feature #72174

closed

Fluent setter for AbstractDomainObject->setPid()

Added by Matthias Schröder over 8 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Extbase
Start date:
2015-12-11
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
Needs Decision

Description

public function setPid($pid) {...}

should not return void but $this to use it fluently.

Actions #1

Updated by Mathias Brodala over 8 years ago

  • Status changed from New to Needs Feedback

Why exactly? There is no domain model/object in TYPO3 which spurs a fluent interface, why should this setter be an exception?

Actions #2

Updated by Frank Nägler over 8 years ago

If we change this we have to change the DomainObjectInterface too, which is a breaking change.

Actions #3

Updated by Matthias Schröder over 8 years ago

This one I came across several times when creating a new domain model object.

I think it would be nice, if all setters implemented the fluent interface (if possible), because it is much ore convenient and improves code readability.

Example:

$event = GeneralUtility::makeInstance(Event::class) 
$event->setPid(101);
$event
    ->setTeaserText($faker->text(100))
    ->setCategory(rand(1, 3))
    ->setVenue($faker->text(15))
    ->setAddress($faker->address)
     ...
;
Actions #4

Updated by Alexander Opitz about 8 years ago

  • Status changed from Needs Feedback to New
  • Target version set to Candidate for Major Version
Actions #5

Updated by Susanne Moog about 4 years ago

  • Category set to Extbase
Actions #6

Updated by Georg Ringer about 4 years ago

  • Sprint Focus set to Needs Decision
Actions #7

Updated by Benni Mack over 3 years ago

  • Status changed from New to Rejected

I see your point here, but considering adding this as "breaking" change for a fluent API seems a bit much. Also, personally, I'd recommend using Factories or the constructor to set up the object, as this brings the code that uses the domain model in a defined state. See latest PHP8 additions, which directly point to such features.

Sorry (also for the late reply).

Actions

Also available in: Atom PDF