Merge pull request #1401 from open-sausages/pulls/4.0/ownership-api

API Mark image tracking as owned
This commit is contained in:
Ingo Schommer 2016-03-08 11:55:01 +13:00
commit 08202f018f
2 changed files with 33 additions and 13 deletions

View File

@ -19,6 +19,16 @@ class SiteTreeFileExtension extends DataExtension {
'BackLinkTracking' => 'SiteTree.ImageTracking' // {@see SiteTreeLinkTracking} 'BackLinkTracking' => 'SiteTree.ImageTracking' // {@see SiteTreeLinkTracking}
); );
/**
* Images tracked by pages are owned by those pages
*
* @config
* @var array
*/
private static $owned_by = array(
'BackLinkTracking'
);
public function updateCMSFields(FieldList $fields) { public function updateCMSFields(FieldList $fields) {
$fields->insertAfter( $fields->insertAfter(
ReadonlyField::create( ReadonlyField::create(

View File

@ -41,13 +41,23 @@ class SiteTreeLinkTracking extends DataExtension {
private static $many_many = array( private static $many_many = array(
"LinkTracking" => "SiteTree", "LinkTracking" => "SiteTree",
"ImageTracking" => "File" "ImageTracking" => "File" // {@see SiteTreeFileExtension}
); );
private static $belongs_many_many = array( private static $belongs_many_many = array(
"BackLinkTracking" => "SiteTree.LinkTracking" "BackLinkTracking" => "SiteTree.LinkTracking"
); );
/**
* Tracked images are considered owned by this page
*
* @config
* @var array
*/
private static $owns = array(
"ImageTracking"
);
private static $many_many_extraFields = array( private static $many_many_extraFields = array(
"LinkTracking" => array("FieldName" => "Varchar"), "LinkTracking" => array("FieldName" => "Varchar"),
"ImageTracking" => array("FieldName" => "Varchar") "ImageTracking" => array("FieldName" => "Varchar")