Skip to content
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

Syncing & Queued Deletes #3

Merged
merged 7 commits into from
Mar 20, 2024
Merged

Syncing & Queued Deletes #3

merged 7 commits into from
Mar 20, 2024

Conversation

kfriars
Copy link
Collaborator

@kfriars kfriars commented Mar 17, 2024

Summary

In order for drafted content to be able to have "dependent" content, we add the notion if syncing and queued deleted.

Status is always synced to dependents when content is saved.
Deletes are queued on dependent content until the parent is published.

Tests

  1. SyncPublishingTest

@kfriars kfriars self-assigned this Mar 17, 2024
@kfriars kfriars requested a review from m-triassi March 18, 2024 14:13
Copy link
Contributor

@m-triassi m-triassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly this all looks quite reasonable to me, barring that nestedPluck() method

Comment on lines +106 to +137
/**
* @return Collection<Publishable&Model>
*/
protected function nestedPluck(string $relation): Collection
{
$this->loadMissing($relation);

$models = [$this];

$relations = explode('.', $relation);

while ($part = array_shift($relations)) {
$results = [];

foreach ($models as $model) {
$related = $model->{$part};

if ($related instanceof Model) {
$results[] = $related;

continue;
}

if ($related instanceof Arrayable) {
foreach ($related as $item) {
$results[] = $item;
}
}
}

$models = $results;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe i'm misunderstanding, but, i'm not sure if this method is needed, last i remember pluck supports the dot notation doesn't it? ie: ->pluck('relation.property')

@kfriars kfriars merged commit 5e67eb6 into main Mar 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants