Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PropertyAccess] RFC: PropertyPath options #5013

Closed
@webmozart

Description

@webmozart

ThePropertyPath class currently makes a list of assumptions:

1. Objects are treated by reference

When the pathauthor.name is modified, the following methods are called:

getAuthor()setName() // on the author

Note thatsetAuthor() is not called.

2. Adders and removers are used if they exist

If a collection is written into the pathtags and the methodsaddTag() andremoveTag() exist, these are used to merge into the old collection instead of accessing the old collection directly via itsArrayAccess interface. The following methods are called:

getTags()addTag(...) // instead of $tags[] = ...removeTag(...) // instead of unset($tags[...])
3. Adders and removers follow English singularization rules

If a property path is calledchildren, the guessed adders and removers areaddChild() andremoveChild().

Limitations

The above assumptions do not hold in all applications:

  1. Sometimes setters should be called (no by-reference handling, see[Form] by_reference when embedding a single object #6965)
  2. Sometimes elements should be written directly into collections even though adders/removers exist ([2.1][Form] CollectionType / PropertyPath BC Break? #4158,[Form] Fixed undefined index in writeProperty when saving value arrays #5257)
  3. For other languages than English, singularization does not work

So, these assumptions should be made configurable. The challenge is how to build this API in an intuitive way.

Alternative 1: Option arrays

The first alternative is to pass the options in an array separately from the property path. For example:

Path:    artikel.stichwörter (= article.tags)Options: array(             'artikel' => array(                 'by_reference' => false,             ),             'artikel.stichwörter' => array(                 'use_adders' => false,                 // or                 'singular' => 'stichwort',             ),         )
Alternative 2: Path flags

The second alternative is to build the configuration options into the path:

artikel{!byref}.stichwörter{!adders}// orartikel{!byref}.stichwörter{singular=stichwort}
Alternative 3: Your suggestions

Do you have any other ideas? What approach do you prefer?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp