sulu / sulu-document-manager

Sulu document manager
sulu.io
6 stars 7 forks source link

Locale behavior and state. #79

Open dantleech opened 8 years ago

dantleech commented 8 years ago

Locales

The system should work as follows:

  1. There should be a default locale.
  2. If a document is persisted without a locale, then the default locale should be used.
  3. The document manager should always have a locale, if there is no locale the document manager is in an invalid state.
  4. If find is called for an already loaded document and no locale is given, the currently registered locale for that document should be used, otherwise the default locale will be assumed.
  5. Same behavior as (4) for persist.
  6. find should NOT rehydrate the document unless the requested locale is different from the currently registered locale, or the rehydrate=false option is given (#78).
  7. Subscribers should always assume that the locale is available, because (3) (#70).

it has been said that always having a locale is not necessary (e.g. for routes in Sulu)

  1. Routes do not have localized properties. The locale therefore does not apply.
  2. Overhead from processing localized listeners for non-localized documents: as there are no localized properties, such listeners will add little to no overhead.
  3. Most property mapping should be happening the MappingSubscriber. In the future this can be optimized to do the minimum amount of work necessary, the MappingSubscriber should aggregate the responsiblity of mapping fields to properties and optimization should happen there - NOT in the subscribers.

    State

Unlike even the Doctrine PHPCR-ODM, Sulu documents currently have more state than just locale, and the state depends on which options were given when calling find, for example load_ghost_content effects the state of the document.

Such state-altering options should combine with the locale to provide the state of the document, and the above numbered rules should also apply.