Source of file CheckConfigsController.php
Size: 5,468 Bytes - Last Modified: 2021-12-23T10:39:12+00:00
/var/www/docs.ssmods.com/process/src/src/Control/CheckConfigsController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 | <?php namespace Sunnysideup\ConfigManager\Control; use SilverStripe\Control\Controller; use SilverStripe\Core\Config\Config; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; use Sunnysideup\ConfigManager\Api\ConfigList; use Sunnysideup\ConfigManager\View\YmlProvider; use Sunnysideup\TableFilterSort\Api\TableFilterSortAPI; class CheckConfigsController extends Controller { protected $title = 'Check configs'; protected $description = 'Runs through all classes and looks for private statics'; private static $url_segment = 'dev/checkconfigs'; /** * Defines methods that can be called directly. * * @var array */ private static $allowed_actions = [ 'index' => 'ADMIN', 'location' => 'ADMIN', 'package' => 'ADMIN', 'model' => 'ADMIN', ]; public function Title() { return $this->title; } public function location() { $location = $this->request->param('ID'); if (! $location) { die('please set a location in the url /dev/checkconfigs/location/framework/ - e.g. framework'); } return (new YmlProvider())->getYmlForLocation($location); } public function model() { return (new YmlProvider()) ->getModel() ; } public function package() { return (new YmlProvider())->getYmlForPackage($this->request->param('ID'), $this->request->param('OtherID')); } public function index($request) { if (class_exists(\Sunnysideup\WebpackRequirementsBackend\View\RequirementsBackendForWebpack::class, true)) { Config::modify()->set( \Sunnysideup\WebpackRequirementsBackend\View\RequirementsBackendForWebpack::class, 'enabled', false ); } TableFilterSortAPI::include_requirements( $tableSelector = '.tfs-holder', $blockArray = [], $jqueryLocation = 'https://code.jquery.com/jquery-3.5.1.min.js', $includeInPage = false, $jsSettings = [ 'rowRawData' => $this->Data(), 'scrollToTopAtPageOpening' => true, 'sizeOfFixedHeader' => 0, 'maximumNumberOfFilterOptions' => 20, 'filtersParentPageID' => '', 'favouritesParentPageID' => '', 'visibleRowCount' => 20, 'startWithOpenFilter' => true, 'dataDictionary' => [ 'Type' => [ 'Label' => 'Type', 'CanFilter' => true, ], 'Vendor' => [ 'Label' => 'Vendor', 'CanFilter' => true, ], 'Package' => [ 'Label' => 'Package', 'CanFilter' => true, ], 'ShorterClassName' => [ 'Label' => 'Class', 'CanFilter' => true, ], 'Property' => [ 'Label' => 'Property', 'CanFilter' => true, ], 'IsDefault' => [ 'Label' => 'Is Default', 'CanFilter' => true, ], 'HasDefault' => [ 'Label' => 'Has Default', 'CanFilter' => false, ], 'HasValue' => [ 'Label' => 'Has Value', 'CanFilter' => true, ], 'Value' => [ 'Label' => 'Value', 'CanFilter' => false, ], 'Default' => [ 'Label' => 'Default Value', 'CanFilter' => false, ], ], ] ); return $this->renderWith('Sunnysideup/ConfigManager/Control/CheckConfigsTable'); } public function Data() { $list = new ConfigList(); $list = $list->getListOfConfigs(); ksort($list); $finalArray = []; $count = 0; foreach ($list as $values) { ++$count; $id = 'row' . $count; $finalArray[$id] = []; $finalArray[$id]['Vendor'] = $values['Vendor']; $finalArray[$id]['Package'] = $values['Package']; $finalArray[$id]['ShorterClassName'] = $values['ShorterClassName']; $finalArray[$id]['Property'] = $values['Property']; $finalArray[$id]['Type'] = $values['Type']; $finalArray[$id]['IsDefault'] = $values['IsDefault'] ? 'yes' : 'no'; $finalArray[$id]['HasDefault'] = $values['HasDefault'] ? 'yes' : 'no'; $finalArray[$id]['HasValue'] = $values['HasValue'] ? 'yes' : 'no'; $finalArray[$id]['Value'] = '<pre>' . print_r($values['Value'], 1) . '</pre>'; $finalArray[$id]['Default'] = '<pre>' . print_r($values['Default'], 1) . '</pre>'; } return $finalArray; } protected function init() { parent::init(); if (! Permission::check('Admin')) { return Security::permissionFailure($this); } } } |