Skip to content

Commit

Permalink
Merge pull request #6 from creative-commoners/pulls/1.0/update
Browse files Browse the repository at this point in the history
Retrieve BaseElement table name rather than using String
  • Loading branch information
robbieaverill committed Feb 8, 2018
2 parents a98ebfd + 633dd01 commit 6bca6ac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -0,0 +1,2 @@
/.travis.yml export-ignore
/codecov.yml export-ignore
9 changes: 9 additions & 0 deletions phpcs.xml.dist
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
</rule>
</ruleset>
4 changes: 4 additions & 0 deletions src/Extensions/ElementalSubsiteExtension.php
Expand Up @@ -32,8 +32,12 @@ public function updateCMSFields(FieldList $fields)
}
}


/**
* Update any requests for elements to limit the results to the current site
*
* @param SQLSelect $query
* @param DataQuery|null $dataQuery
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
Expand Down
9 changes: 8 additions & 1 deletion src/Extensions/ElementalSubsitesPageExtension.php
Expand Up @@ -34,7 +34,14 @@ public function onAfterDuplicateToSubsite($originalPage)
$duplicateElement = $originalElement->duplicate(true);

// manually set the ParentID of each element, so we don't get versioning issues
DB::query(sprintf("UPDATE Element SET ParentID = %d WHERE ID = %d", $duplicateElementalArea->ID, $duplicateElement->ID));
DB::query(
sprintf(
"UPDATE %s SET ParentID = %d WHERE ID = %d",
DataObject::getSchema()->tableName(BaseElement::class),
$duplicateElementalArea->ID,
$duplicateElement->ID
)
);
}
}
}

0 comments on commit 6bca6ac

Please sign in to comment.