diff --git a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md index f802ee854..e8650ca43 100644 --- a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md +++ b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md @@ -27,22 +27,23 @@ use SilverStripe\ORM\DataObject; class MyStagedModel extends DataObject { private static $extensions = [ - Versioned::class + Versioned::class, ]; } ``` Alternatively, staging can be disabled, so that only versioned changes are tracked for your model. This -can be specified by setting the constructor argument to "Versioned" - +can be specified by using the `.versioned` service variant that provides only version history, and no +staging. ```php use SilverStripe\ORM\DataObject; +use SilverStripe\Versioned\Versioned; class VersionedModel extends DataObject { private static $extensions = [ - "SilverStripe\\ORM\\Versioning\\Versioned('Versioned')" + Versioned::class . '.versioned', ]; } ``` @@ -310,6 +311,19 @@ class Banner extends Page Note that ownership cannot be used with polymorphic relations. E.g. has_one to non-type specific `DataObject`. +#### Unversioned dataobject ownership + +Ownership can be used with non-versioned dataobjects, as the necessary functionality is included by default +by the versioned object through the `[api:SilverStripe\Versioned\RecursivePublishable]` extension which is +applied to all objects. + +However, it is important to note that even when saving un-versioned objects, it is necessary to use +`->publishRecursive()` to trigger a recursive publish. + +`owns` works the same regardless of whether these objects are versioned, so you can use any combination of +versioned or unversioned dataobjects. You only need to call `->recursivePublish()` on the top most +object in the tree. + #### DataObject ownership with custom relations In some cases you might need to apply ownership where there is no underlying db relation, such as diff --git a/src/Forms/Form.php b/src/Forms/Form.php index 0da09cbd6..c8ccbf116 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -173,7 +173,7 @@ class Form extends ViewableData implements HasRequestHandler * another template for customisation. * * @see Form->setTemplate() - * @var string|null + * @var string|array|null */ protected $template; @@ -974,7 +974,7 @@ class Form extends ViewableData implements HasRequestHandler * Set the SS template that this form should use * to render with. The default is "Form". * - * @param string $template The name of the template (without the .ss extension) + * @param string|array $template The name of the template (without the .ss extension) or array form * @return $this */ public function setTemplate($template) @@ -986,7 +986,7 @@ class Form extends ViewableData implements HasRequestHandler /** * Return the template to render this form with. * - * @return string + * @return string|array */ public function getTemplate() { diff --git a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php index 8affff5d6..b5a4b5baa 100644 --- a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php +++ b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php @@ -44,7 +44,6 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler protected $component; /** - * * @var DataObject */ protected $record; @@ -161,7 +160,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler * complete controller with gaps for extra functionality. This, for example, would be a better way * of letting Security/login put its log-in form inside a UI specified elsewhere. * - * @return Form + * @return Form|HTTPResponse */ public function ItemEditForm() { @@ -466,10 +465,12 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler } // Save form and any extra saved data into this dataobject - $form->saveInto($this->record); - $this->record->write(); + $form->saveInto($this->record); + $this->record->write(); + $this->extend('onAfterSave', $this->record); + $extraData = $this->getExtraSavedData($this->record, $list); - $list->add($this->record, $extraData); + $list->add($this->record, $extraData); return $this->record; } diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 9c6e7ba66..9c55508ed 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -100,6 +100,7 @@ use stdClass; * * @property int $ID ID of the DataObject, 0 if the DataObject doesn't exist in database. * @property int $OldID ID of object, if deleted + * @property string $Title * @property string $ClassName Class name of the DataObject * @property string $LastEdited Date and time of DataObject's last modification. * @property string $Created Date and time of DataObject creation.