Source of file TeamPageController.php
Size: 2,164 Bytes - Last Modified: 2021-12-23T10:59:45+00:00
/var/www/docs.ssmods.com/process/src/src/TeamPageController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | <?php namespace WWN\Team; use Exception; use PageController; use SilverStripe\Control\Controller; use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\Convert; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\PaginatedList; use SilverStripe\View\ArrayData; /** * TeamPage Controller * * @package wwn-team */ class TeamPageController extends PageController { private static $allowed_actions = [ 'showGroup', ]; private static $url_handlers = [ '$URLSegment!' => 'showGroup', ]; /** * @var int */ public $groupId = 0; /** * @return PaginatedList * @throws Exception */ public function TeamGroups() { return TeamGroup::get()->sort('SortOrder ASC'); } /** * @return PaginatedList * @throws Exception */ public function TeamPlatoons() { return TeamPlatoon::get()->sort('SortOrder ASC'); } /** * Detail view * * @return DBHTMLText|HTTPResponse * @throws Exception */ public function showGroup() { $name = Convert::raw2sql($this->getRequest()->param('URLSegment')); $filter = [ 'URLSegment' => $name, ]; $group = TeamGroup::get()->filter($filter)->first(); if (! $group) { $url = explode('/', $this->getRequest()->getURL()); return $this->redirect($url[0].'/'); } else { $this->groupId = $group->ID; $customise = [ 'Group' => $group, 'ExtraBreadcrumb' => ArrayData::create( [ 'Title' => $group->Name, 'Link' => $this->Link($name), ] ), 'Vehicles' => $group->Vehicles()->sort('Sort ASC'), 'Members' => $group->TeamMembers()->sort('SortOrder ASC'), ]; $renderWith = [ 'WWN/Team/GroupPage', 'Page', ]; return $this->customise($customise)->renderWith($renderWith); } } } |