Tailor\Behaviors\DraftController

Overview

DraftController is a modifier to FormController to enable draft records

Extends

Public Properties

There are no public properties in the class.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected Model $primaryModel

model used by the form

protected Model $model

model used by the form

protected string $draftId

protected string $deleteMethod

protected array $modelsToSave

modelsToSave are models that require saving

Show inherited protected properties

Inherited Protected Properties


Public Methods

public create()

public create(): void 

Controller "create" action used for creating new model records.

public draftGetDraftModel()

public draftGetDraftModel(): void

public draftGetPrimaryModel()

public draftGetPrimaryModel(): void

public getDraftId()

public getDraftId(): string 

public initDraft()

public initDraft($model, $context = null): void

public isDraftMode()

public isDraftMode(): bool 

public makeDraftRedirect()

public makeDraftRedirect($context = null, $model = null, $queryParams = []): void

public makeDraftRedirectToClosest()

public makeDraftRedirectToClosest($model): void

public makeMultisiteDraftRedirect()

public makeMultisiteDraftRedirect($context = null, $model = null): void

public onCommitDraft()

public onCommitDraft($recordId = null): void

onCommitDraft is saving a draft without publishing it

public onCreateDraft()

public onCreateDraft($recordId = null, $context = null): void

onCreateDraft is creating a new draft from a published record

public onDiscardDraft()

public onDiscardDraft($recordId = null, $context = null): void

onDiscardDraft deletes the draft

public onPublishDraft()

public onPublishDraft($recordId = null, $context = null): void

onPublishDraft is saving a draft and publishing it

public update()

public update(int $recordId = null, string $context = null): void 

Controller "update" action used for updating existing model records.

Show inherited public methods

Inherited Public Methods

Protected Methods

protected addHandlerToSiteSwitcher()

protected addHandlerToSiteSwitcher(): void

protected deferPurgedSaveAttributes()

protected deferPurgedSaveAttributes(
    October\Rain\Database\Model $model,
    array $attributesToPurge
): void 

deferPurgedSaveAttributes removes an array of attributes from the model. If the model implements the Purgeable trait, this is preferred over the internal logic.

protected performSaveOnModel()

protected performSaveOnModel($model, $data, $options = null): void

performSaveOnModel saves complex data against a model inside a database transaction.

protected prepareModelsToSave()

protected prepareModelsToSave(
    October\Rain\Database\Model $model,
    array $saveData
): array 

prepareModelsToSave takes a model and fills it with data from a multidimensional array. If an attribute is found to be a relationship, that relationship is also filled.

$modelsToSave = $this->prepareModelsToSave($model, [...]);

foreach ($modelsToSave as $modelToSave) {
    $modelToSave->save();
}

protected setModelAttributes()

protected setModelAttributes(
    October\Rain\Database\Model $model,
    array $saveData,
    $attrName = ''
): void 

setModelAttributes sets a data collection to a model attributes, relations are also set.

Show inherited protected methods

Inherited Protected Methods