public function duplicateSubsiteRelations($originalPage)
    {
        $thisClass = $originalPage->ClassName;
        $relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations');

        if ($relations && !empty($relations)) {
            foreach ($relations as $relation) {
                $items = $originalPage->$relation();
                foreach ($items as $item) {
                    $duplicateItem = $item->duplicate(false);
                    $duplicateItem->{$thisClass.'ID'} = $this->owner->ID;
                    $duplicateItem->write();
                }
            }
        }
    }
public function duplicateSubsiteRelations($originalPage)
    {
        $thisClass = $originalPage->ClassName;
        $relations = Config::inst()->get($thisClass, 'duplicate_to_subsite_relations');

        if ($relations && !empty($relations)) {
            foreach ($relations as $relation) {
                $items = $originalPage->$relation();
                foreach ($items as $item) {
                    $duplicateItem = $item->duplicate(false);
                    $duplicateItem->{$thisClass.'ID'} = $this->owner->ID;
                    $duplicateItem->write();
                }
            }
        }
    }
public function duplicateSubsiteRelations ( $ originalPage ) { $ thisClass = $ originalPage -> ClassName ; $ relations = Config :: inst ( ) -> get ( $ thisClass , 'duplicate_to_subsite_relations' ) ; if ( $ relations && ! empty ( $ relations ) ) { foreach ( $ relations as $ relation ) { $ items = $ originalPage -> $ relation ( ) ; foreach ( $ items as $ item ) { $ duplicateItem = $ item -> duplicate ( false ) ; $ duplicateItem -> { $ thisClass . 'ID' } = $ this -> owner -> ID ; $ duplicateItem -> write ( ) ; } } } }
Duplicate relations using a static property to define
which ones we want to duplicate

It may be that some relations are not diostinct to sub site so can stay
whereas others may need to be duplicated

@deprecated 2.2..3.0 Use the "cascade_duplicates" config API instead
@param SiteTree $originalPage
Duplicate relations using a static property to define which ones we want to duplicate