class Cloner (View source)

A class to copy pages and page versions.

Properties

protected Connection $connection
protected EntityManagerInterface $entityManager
protected Service $siteService
protected Date $dateHelper
protected EventDispatcherInterface $eventDispatcher

Methods

__construct(EntityManagerInterface $entityManager, Service $siteService, Date $dateHelper, EventDispatcherInterface $eventDispatcher)

No description

clonePage(Page $page, ClonerOptions $options, Page $newParentPage = null, TreeInterface $site = null)

Duplicate a page and return the newly created page.

cloneCollection(Collection $c, ClonerOptions $options)

Create a clone of a collection, and all its versions, contents and attributes.

cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options)

Create a copy of a collection version to another collection.

bool
cloneBlock(Block $block, Collection $destinationCollection)

Create an alias of a block to another collection.

string
getUniquePageName(string $pageName, int $parentID)

Get the name of a page that's unique for the parent.

string
getUniquePageHandle(string $handle, int $parentID)

Get the handle of a page that's unique for the parent.

copyData(ClonerOptions $options, array $cIDs, array $cvIDs = null)

Copy the data from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

copyAttributes(array $cIDs, array $cvIDs = null)

Copy the attributes from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

copyFeatureAssignments(array $cIDs, array $cvIDs = null)

Copy the feature assignments from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

copyCustomStyles(array $cIDs, array $cvIDs = null)

Copy the custom theme styles from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

copyBlocks(int[] $cIDs, array $cvIDs = null, array $bIDs = null, int|null $newBlockDisplayOrder = null)

Copy the blocks from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

copyAreaStyles(array $cIDs, array $cvIDs = null)

Copy the area styles from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

directCopy(string $table, string|string[] $copyFields, array $keyFields, string|null $from = null)

No description

Details

__construct(EntityManagerInterface $entityManager, Service $siteService, Date $dateHelper, EventDispatcherInterface $eventDispatcher)

Parameters

EntityManagerInterface $entityManager
Service $siteService
Date $dateHelper
EventDispatcherInterface $eventDispatcher

Page|Stack clonePage(Page $page, ClonerOptions $options, Page $newParentPage = null, TreeInterface $site = null)

Duplicate a page and return the newly created page.

Parameters

Page $page The page (or the stack) to be copied
ClonerOptions $options The options for the cloning process
Page $newParentPage The page under which this page should be copied to
TreeInterface $site the destination site (used if $newParentPage is NULL)

Return Value

Page|Stack

Collection cloneCollection(Collection $c, ClonerOptions $options)

Create a clone of a collection, and all its versions, contents and attributes.

Parameters

Collection $c the collection to be cloned
ClonerOptions $options the options for the cloning process

Return Value

Collection

Version cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options)

Create a copy of a collection version to another collection.

Parameters

Version $cvSource
Collection $cDestination
ClonerOptions $options the options for the cloning process

Return Value

Version

bool cloneBlock(Block $block, Collection $destinationCollection)

Create an alias of a block to another collection.

Parameters

Block $block
Collection $destinationCollection

Return Value

bool returns FALSE if $block is not cloned because it's already present in $destinationCollection, TRUE otherwise

protected string getUniquePageName(string $pageName, int $parentID)

Get the name of a page that's unique for the parent.

Parameters

string $pageName
int $parentID

Return Value

string

protected string getUniquePageHandle(string $handle, int $parentID)

Get the handle of a page that's unique for the parent.

Parameters

string $handle
int $parentID

Return Value

string

protected copyData(ClonerOptions $options, array $cIDs, array $cvIDs = null)

Copy the data from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

ClonerOptions $options
array $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions

protected copyAttributes(array $cIDs, array $cvIDs = null)

Copy the attributes from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

array $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions

protected copyFeatureAssignments(array $cIDs, array $cvIDs = null)

Copy the feature assignments from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

array $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions

protected copyCustomStyles(array $cIDs, array $cvIDs = null)

Copy the custom theme styles from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

array $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions

protected copyBlocks(int[] $cIDs, array $cvIDs = null, array $bIDs = null, int|null $newBlockDisplayOrder = null)

Copy the blocks from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

int[] $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions
array $bIDs An array with the source and destination block IDs, or NULL to copy all the blocks
int|null $newBlockDisplayOrder The display order of the new blocks (NULL: copy)

protected copyAreaStyles(array $cIDs, array $cvIDs = null)

Copy the area styles from one collection version (or all versions of a collection) to another collection version (or all versions of a collection).

Parameters

array $cIDs An array with the ID of the source and destination collections
array $cvIDs An array with the source and destination collection versions, or NULL to copy the data of all the collection versions

private directCopy(string $table, string|string[] $copyFields, array $keyFields, string|null $from = null)

Parameters

string $table
string|string[] $copyFields
array $keyFields An array with key fields; keys are the field names; values are: NULL (to copy the data), mixed[] to change the value
string|null $from