-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docs for new Path Enumerable trait #227
base: develop
Are you sure you want to change the base?
Conversation
|
||
Method | Description | ||
------ | ----------- | ||
`->getParent()` | Gets the parent record of the current record, if one exists. Returns a `Collection` with zero or one parent record. This is similar to the `parent` relation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this return a collection instead of a single instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question - might have to check that. I just went off the signature of the method. Might be PHPStan related?
// ... | ||
|
||
// Defines the column used for storing the parent ID. | ||
const PARENT_ID = 'parent_id'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it an absolute hard requirement that we have a parent_id column? Is there anyway at all that we could use some magic to eliminate the need for the parent_id column and just rely on the structure of the path column? I'm not familiar with the inner workings of the code at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts being that I really want the filesystem itself to remain the single source of truth, the purpose of the database layer is to provide an easy way to manage additional metadata on the individual files as well as make it easier to improve performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the parent ID would give us a recovery process if the hierarchy got corrupted - we'd be able to reconstruct all the paths based off the parent IDs. It's also used to determine if the record has actually moved or not (and ensuring that we have the correct path of the parent when moving the record to formulate the path of the current record and anything underneath - see the moveToNewParent
method in the trait PR for more info on that)
While this trait is mainly for the media library changes, it can most certainly be used for other things, so I don't think we should necessarily be too "strict" about designing this around our requirements for the media library.
Refs: https://github.com/wintercms/storm/pull/155/files