PHP Class Devise\Pages\PageManager

Datei anzeigen Open project: devisephp/cms Class Usage Examples

Public Properties

Property Type Description
$errors array Errors are kept in an array and can be used later if validation fails and we want to know why
$message string This is a message that we can store why the validation failed
$warnings [type] [$warnings description]

Protected Properties

Property Type Description
$FieldManager Devise\Pages\Fields\FieldManager FieldManager lets us manage the fields
$FieldsRepository Devise\Pages\Fields\FieldsRepository FieldsRepository returns information about fields
$Page Page DvsPage model to fetch database dvs_pages
$PageFields array ..
$PageVersionManager PageVersionManager PageVersionManager lets us manage versions of a page
$Validator Illuminate\Validation\Factory Validator is used to validate page rules

Public Methods

Method Description
__construct ( DvsPage $Page, PageVersionManager $PageVersionManager, PageVersionsRepository $PageVersionsRepository, FieldsRepository $FieldsRepository, FieldManager $FieldManager, Framework $Framework, RoutesGenerator $RoutesGenerator, DvsLanguage $Language ) Construct a new page manager
copyPage ( integer $fromPageId, array $input ) : DvsPage Takes the input provided and runs the create method after stripping necessary fields.
createNewPage ( $input ) : boolean Validates and creates a page with the given input
destroyPage ( integer $id ) : boolean Destroys a page
markContentRequestedFieldsComplete ( $pageId ) : string Marks all page's fields with a "true" content_requested value as complete
toggleABTesting ( [type] $pageId, [type] $isEnabled ) : [type] [toggleABTesting description]
updatePage ( integer $id, array $input ) : boolean Validates and updates a page with the given input
updatePageVersionABTestingAmount ( [type] $pageVersionId, [type] $amount ) : [type] [updatePageVersionABTestingAmount description]
updatePageVersionDates ( integer $pageVersionId, array $input ) : void Updates the page version dates
updatePageVersionView ( [type] $pageVersionId, [type] $view ) : [type] Updates the page version view

Protected Methods

Method Description
cacheDeviseRoutes ( ) : [type] Cache the devise routes, and make sure to catch an exception. Exception thrown is likely due to serialization error caused by caching routes with closures in them
createPageFromInput ( array $input ) : DvsPage Creates a page from the given input data
findAvailableRoute ( string $suggestedRoute, $languageId ) : string This helper method keeps looking through suggested route names and adding a number onto the suggested route until it finds an available one that isn't taken in the database. We don't want route names to be the same ever as they should be unique so this helps us accomplish that.
isValidInputForNewPage ( [type] $input ) : boolean [isValidInputForNewPage description]
setTranslatedFromPageId ( $fromPage, array &$input ) : array This ensures that we are translating from the correct "parent" page.
setTranslatedFromRouteName ( $fromPage, array &$input ) Sets the route_name equal to the orignal page's route_name

Method Details

__construct() public method

Construct a new page manager
public __construct ( DvsPage $Page, PageVersionManager $PageVersionManager, PageVersionsRepository $PageVersionsRepository, FieldsRepository $FieldsRepository, FieldManager $FieldManager, Framework $Framework, RoutesGenerator $RoutesGenerator, DvsLanguage $Language )
$Page DvsPage
$PageVersionManager PageVersionManager
$PageVersionsRepository PageVersionsRepository
$FieldsRepository Devise\Pages\Fields\FieldsRepository
$FieldManager Devise\Pages\Fields\FieldManager
$Framework Devise\Support\Framework
$RoutesGenerator RoutesGenerator
$Language DvsLanguage

cacheDeviseRoutes() protected method

Cache the devise routes, and make sure to catch an exception. Exception thrown is likely due to serialization error caused by caching routes with closures in them
protected cacheDeviseRoutes ( ) : [type]
return [type]

copyPage() public method

Takes the input provided and runs the create method after stripping necessary fields.
public copyPage ( integer $fromPageId, array $input ) : DvsPage
$fromPageId integer
$input array
return DvsPage

createNewPage() public method

Validates and creates a page with the given input
public createNewPage ( $input ) : boolean
return boolean

createPageFromInput() protected method

Creates a page from the given input data
protected createPageFromInput ( array $input ) : DvsPage
$input array
return DvsPage

destroyPage() public method

Destroys a page
public destroyPage ( integer $id ) : boolean
$id integer
return boolean

findAvailableRoute() protected method

This helper method keeps looking through suggested route names and adding a number onto the suggested route until it finds an available one that isn't taken in the database. We don't want route names to be the same ever as they should be unique so this helps us accomplish that.
protected findAvailableRoute ( string $suggestedRoute, $languageId ) : string
$suggestedRoute string
return string

isValidInputForNewPage() protected method

[isValidInputForNewPage description]
protected isValidInputForNewPage ( [type] $input ) : boolean
$input [type]
return boolean

markContentRequestedFieldsComplete() public method

Marks all page's fields with a "true" content_requested value as complete
public markContentRequestedFieldsComplete ( $pageId ) : string
return string

setTranslatedFromPageId() protected method

This happens when a user creates a page and then copies that "parent" page to a "child" page. When the user tries to copy the "child" page to a "grandchild" page. We want the "grandchild" to be a "child" instead of a "grandchild". This keeps page nesting down to 1 level instead of nesting under many levels.
protected setTranslatedFromPageId ( $fromPage, array &$input ) : array
$input array
return array

setTranslatedFromRouteName() protected method

Sets the route_name equal to the orignal page's route_name
protected setTranslatedFromRouteName ( $fromPage, array &$input )
$input array

toggleABTesting() public method

[toggleABTesting description]
public toggleABTesting ( [type] $pageId, [type] $isEnabled ) : [type]
$pageId [type]
$isEnabled [type]
return [type]

updatePage() public method

Validates and updates a page with the given input
public updatePage ( integer $id, array $input ) : boolean
$id integer
$input array
return boolean

updatePageVersionABTestingAmount() public method

[updatePageVersionABTestingAmount description]
public updatePageVersionABTestingAmount ( [type] $pageVersionId, [type] $amount ) : [type]
$pageVersionId [type]
$amount [type]
return [type]

updatePageVersionDates() public method

Updates the page version dates
public updatePageVersionDates ( integer $pageVersionId, array $input ) : void
$pageVersionId integer
$input array
return void

updatePageVersionView() public method

Updates the page version view
public updatePageVersionView ( [type] $pageVersionId, [type] $view ) : [type]
$pageVersionId [type]
$view [type]
return [type]

Property Details

$FieldManager protected_oe property

FieldManager lets us manage the fields
protected FieldManager,Devise\Pages\Fields $FieldManager
return Devise\Pages\Fields\FieldManager

$FieldsRepository protected_oe property

FieldsRepository returns information about fields
protected FieldsRepository,Devise\Pages\Fields $FieldsRepository
return Devise\Pages\Fields\FieldsRepository

$Page protected_oe property

DvsPage model to fetch database dvs_pages
protected Page $Page
return Page

$PageFields protected_oe static_oe property

..
protected static array $PageFields
return array

$PageVersionManager protected_oe property

PageVersionManager lets us manage versions of a page
protected PageVersionManager,Devise\Pages $PageVersionManager
return PageVersionManager

$Validator protected_oe property

Validator is used to validate page rules
protected Illuminate\Validation\Factory $Validator
return Illuminate\Validation\Factory

$errors public_oe property

Errors are kept in an array and can be used later if validation fails and we want to know why
public array $errors
return array

$message public_oe property

This is a message that we can store why the validation failed
public string $message
return string

$warnings public_oe property

[$warnings description]
public [type] $warnings
return [type]