Tailor\Behaviors\PreviewController

Overview

PreviewController adds the ability to preview a record based on a CMS page

Extends

Public Properties

There are no public properties in the class.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected Page $previewPageName

protected Blueprint $activeSource

protected string $componentName

protected array $modelsToSave

modelsToSave are models that require saving

Show inherited protected properties

Inherited Protected Properties


Public Methods

public static clearCache()

public static clearCache(Cms\Classes\Theme $theme): void

clearCache clears front-end run-time cache.

public hasPreviewPage()

public hasPreviewPage(): bool 

public onPreview()

public onPreview($recordId = null): void

onPreview previews the record

public setPreviewPageContext()

public setPreviewPageContext($componentName, $activeSource): void

Show inherited public methods

Inherited Public Methods

Protected Methods

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 static getPreviewPageCacheKey()

protected static getPreviewPageCacheKey($theme): void

getPreviewPageCacheKey returns a cache key for this record.

protected getPreviewPageName()

protected getPreviewPageName(): string|null 

protected getTheme()

protected getTheme(): void

getTheme returns the theme to source snippets

protected lookupPreviewPage()

protected lookupPreviewPage($theme, $handle): void

lookupPreviewPage returns the preview page for a specified handle.

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