modmore / Gitify

Command line toolkit to make managing a MODX site in git a lot easier.
MIT License
122 stars 55 forks source link

Support relations (aggregate/composite) in a way that makes sense to humans #6

Open Mark-H opened 9 years ago

Mark-H commented 9 years ago

It would be nice to - in a similar way the content works - make use of subdirectories to store relations.

A model mpPackage with one-to-many mpVersion objects could be represented in the .gitify like this:

data:
  packages:
    class: mpPackage
    primary: name
    relations: 
       versions:
         class: mpVersion
         alias: Version 
         primary: signature

which would then result in a directory structure like this for a one-to-many relation:

_data/
  packages/
    redactor.yaml
    redactor/
      versions/
        1.5.0-pl.yaml

A one-to-one relation, for example modUser/modUserProfile, could be in the .gitify file like this:

data:
  packages:
    class: modUser
    primary: username
    relations: 
       profile:
         class: modUserProfile
         alias: Profile

As it's one-to-one, there would (ideally) be no need to specify a primary. Gitify could fetch that from the model and base it off the modUser record.

The profile file would be stored with the name from the reference ("profile") in a directory with the primary from the modUser, like so:

_data/
  users/
    marksusername.yaml
    marksusername/
      profile.yaml

Of course combinations and multiple relations need to be supported.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4323722-support-relations-aggregate-composite-in-a-way-that-makes-sense-to-humans?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F2783338&utm_medium=issues&utm_source=github).
isaacniebeling commented 9 years ago

Would also be good to do this for template variable values. Either store TV values as subdirectory data (less optimal) or within the resource's html file (more optimal, from an editing perspective).

Mark-H commented 9 years ago

Maybe with one-to-(one/many) relations we could skip adding extra directories and files, instead adding it right in to the main object.. like the example with the package/versions, that could in redactor.yaml contain a versions array with all the versions..

Mark-H commented 9 years ago

And with plugin events (#14) that would be like..

data:
  packages:
    class: modPlugin
    primary: name
    relations: 
       events:
         class: modPluginEvent
         alias: Events
name: MyPlugin
description: best one ever
events:
  -
    event: OnHandleRequest
    priority: 5
    propertyset: 0
  -
    event: OnDocFormRender
    priority: 2
    propertyset: 0

-----

$hello = 'Hi!';
$world = 'Earth';

$event->output($hello . $world);