| 1 | <?php |
||
| 2 | |||
| 3 | namespace DNADesign\ElementalSubsites\Extensions; |
||
| 4 | |||
| 5 | use DNADesign\Elemental\Models\BaseElement; |
||
| 6 | use DNADesign\Elemental\Models\ElementalArea; |
||
| 7 | use Page; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use SilverStripe\ORM\DataExtension; |
||
| 9 | use SilverStripe\ORM\DataObject; |
||
| 10 | use SilverStripe\ORM\DB; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @package elemental |
||
| 14 | */ |
||
| 15 | class ElementalSubsitePageExtension extends DataExtension |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * If the page is duplicated across subsites, copy the elements across too. |
||
| 19 | * |
||
| 20 | * @return Page The duplicated page |
||
| 21 | */ |
||
| 22 | public function onAfterDuplicateToSubsite($originalPage) |
||
| 23 | { |
||
| 24 | /** @var ElementalArea $originalElementalArea */ |
||
| 25 | $originalElementalArea = $originalPage->getComponent('ElementalArea'); |
||
| 26 | |||
| 27 | $duplicateElementalArea = $originalElementalArea->duplicate(false); |
||
| 28 | $duplicateElementalArea->write(); |
||
| 29 | |||
| 30 | $this->owner->ElementalAreaID = $duplicateElementalArea->ID; |
||
| 31 | $this->owner->write(); |
||
| 32 | |||
| 33 | foreach ($originalElementalArea->Items() as $originalElement) { |
||
| 34 | /** @var BaseElement $originalElement */ |
||
| 35 | $duplicateElement = $originalElement->duplicate(true); |
||
| 36 | |||
| 37 | // manually set the ParentID of each element, so we don't get versioning issues |
||
| 38 | DB::query( |
||
| 39 | sprintf( |
||
| 40 | "UPDATE %s SET ParentID = %d WHERE ID = %d", |
||
| 41 | DataObject::getSchema()->tableName(BaseElement::class), |
||
| 42 | $duplicateElementalArea->ID, |
||
| 43 | $duplicateElement->ID |
||
| 44 | ) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths