silverstripe-cms/code/Model/SiteTreeFileFormFactoryExtension.php
Damian Mooyman 6c616f5f7a API Implement polymorphic sitetree link tracking (#2123)
* WIP Implement polymorphic sitetree link tracking

* Update unit tests
Merge SiteTreeTrackedPage into SiteTree directly

* Fix bugs and issues

* Fix support for file link tracking

* Add missing use

* Add back deprecated extension

* Remove obsolete belongs_many_many

* Update deprecations

* BUG Ensure non-SiteTree records support link tracking

* Safer changed check

* Shift file tracking test to assets module

* Better check for live stage on versioning

* Deprecate method

* Cleanup virtualpage

* Clear records on delete

* Ensure upgrade task occurs on draft

* fix linting
2018-04-06 15:53:57 +12:00

44 lines
1.3 KiB
PHP

<?php
namespace SilverStripe\CMS\Model;
use SilverStripe\Assets\File;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\TabSet;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Admin\Forms\UsedOnTable;
use SilverStripe\Versioned\RecursivePublishable;
/**
* @deprecated 5.0
* No longer required - superceded by {@see UsedOnTable}
*
* Extension applied to {@see FileFormFactory} to decorate with a "Used on:" information area.
* Uses tracking provided by {@see SiteTreeFileExtension} to generate this.
*
* @property File $owner
*/
class SiteTreeFileFormFactoryExtension extends DataExtension
{
public function updateFormFields(FieldList $fields, $controller, $formName, $context)
{
/** @var TabSet $tabset */
$tabset = $fields->fieldByName('Editor');
if (!$tabset) {
return;
}
$class = UsedOnTable::class;
Deprecation::notice('5.0', "Use the $class to show this table");
$usedOnField = UsedOnTable::create('UsedOnTableReplacement');
$usedOnField->setRecord($context['Record']);
// Add field to new tab
/** @var Tab $tab */
$tab = Tab::create('Usage', _t(__CLASS__ . '.USAGE', 'Usage'), $usedOnField);
$tabset->push($tab);
}
}