diff --git a/src/Reports/ElementTypeReport.php b/src/Reports/ElementTypeReport.php index c77e1214..cb9d1aa1 100644 --- a/src/Reports/ElementTypeReport.php +++ b/src/Reports/ElementTypeReport.php @@ -62,7 +62,8 @@ protected function getElementTypes() public function columns() { - $inUseReport = new ElementsInUseReport; + // Get from Injector so substitutions are used... + $inUseReport = ElementsInUseReport::singleton(); return [ 'Icon' => [ @@ -73,7 +74,9 @@ public function columns() 'formatting' => function ($value, $item) use ($inUseReport) { return sprintf( '%s', - $inUseReport->getLink('?filters[ClassName]='. $item->ClassName), + $inUseReport->getLink( + '?filters[' . $inUseReport::CLASS_NAME_FILTER_KEY . ']=' . $item->ClassName + ), $item->Type, $item->TypeNice ); diff --git a/src/Reports/ElementsInUseReport.php b/src/Reports/ElementsInUseReport.php index f52f1676..1d15adaf 100644 --- a/src/Reports/ElementsInUseReport.php +++ b/src/Reports/ElementsInUseReport.php @@ -11,6 +11,11 @@ class ElementsInUseReport extends Report { + /** + * The string used in GET params to filter the records in this report by element type + */ + const CLASS_NAME_FILTER_KEY = 'ClassName'; + public function title() { return _t(__CLASS__ . '.ReportTitle', 'Content blocks in use'); @@ -21,8 +26,8 @@ public function sourceRecords($params = []) /** @var DataList $elements */ $elements = BaseElement::get()->exclude(['ClassName' => BaseElement::class]); - if (isset($params['ClassName'])) { - $className = $this->unsanitiseClassName($params['ClassName']); + if (isset($params[static::CLASS_NAME_FILTER_KEY])) { + $className = $this->unsanitiseClassName($params[static::CLASS_NAME_FILTER_KEY]); $elements = $elements->filter(['ClassName' => $className]); } @@ -122,7 +127,7 @@ public function getBreadcrumbs() // Only apply breadcrumbs if a "ClassName" filter is applied. This implies that we came from the // "element type report". - if (!isset($params['ClassName'])) { + if (!isset($params[static::CLASS_NAME_FILTER_KEY])) { return []; }