Merge pull request #7695 from open-sausages/pulls/4/versions-of-atlantis

Update framework docs / phpdoc for versioning changes
This commit is contained in:
Robbie Averill 2017-12-17 16:33:59 +13:00 committed by GitHub
commit cd9695eda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 12 deletions

View File

@ -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

View File

@ -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()
{

View File

@ -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;
}

View File

@ -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.