Skip to content

Commit

Permalink
PR fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Apr 6, 2021
1 parent 5fe5b63 commit 7d10a30
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions _config/versionedownership.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ OnlyIf:
SilverStripe\Admin\LeftAndMain:
extensions:
RecursivePublishableHandler: SilverStripe\Versioned\RecursivePublishableHandler
---
Name: versionedrecursivestages
---
SilverStripe\Core\Injector\Injector:
SilverStripe\Versioned\RecursiveStagesInterface:
class: SilverStripe\Versioned\RecursiveStagesService
24 changes: 24 additions & 0 deletions src/RecursiveStagesInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace SilverStripe\Versioned;

use SilverStripe\ORM\DataObject;

/**
* Interface RecursiveStagesInterface
*
* Interface for @see RecursiveStagesService to provide the capability to for "smart" durty model state
* which can cover nested models
*/
interface RecursiveStagesInterface
{

/**
* Determine if content differs on stages including nested objects
*
* @param DataObject $object
* @param string $mode
* @return bool
*/
public function stagesDifferRecursive(DataObject $object, string $mode): bool;
}
5 changes: 1 addition & 4 deletions src/RecursiveStagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
namespace SilverStripe\Versioned;

use SilverStripe\Core\Injector\Injectable;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;

/**
* Class RecursiveStagesService
*
* Functionality for detecting the need of publishing nested objects owned by common parent / ancestor object
*
* @package SilverStripe\Versioned
*/
class RecursiveStagesService
class RecursiveStagesService implements RecursiveStagesInterface
{
use Injectable;

Expand Down
6 changes: 5 additions & 1 deletion src/Versioned.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Resettable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\FieldList;
Expand Down Expand Up @@ -2071,7 +2072,10 @@ public function stagesDiffer()
*/
public function stagesDifferRecursive(string $mode = RecursiveStagesService::OWNERSHIP_STRONG): bool
{
return RecursiveStagesService::singleton()->stagesDifferRecursive($this->owner, $mode);
/** @var RecursiveStagesInterface $service */
$service = Injector::inst()->get(RecursiveStagesInterface::class);

return $service->stagesDifferRecursive($this->owner, $mode);
}

/**
Expand Down

0 comments on commit 7d10a30

Please sign in to comment.