/** * @param String $name * @param String $title * @param String $managedClass * @param String $filterField * @param Group|SS_List $records One or more {@link Group} or {@link PermissionRole} records * used to determine permission checkboxes. * Caution: saveInto() can only be used with a single record, all inherited permissions will be marked readonly. * Setting multiple groups only makes sense in a readonly context. (Optional) */ public function __construct($name, $title, $managedClass, $filterField, $records = null) { $this->filterField = $filterField; $this->managedClass = $managedClass; if ($records instanceof SS_List) { $this->records = $records; } elseif ($records instanceof Group) { $this->records = new ArrayList(array($records)); } elseif ($records) { throw new InvalidArgumentException('$record should be either a Group record, or a SS_List of Group records'); } // Get all available codes in the system as a categorized nested array $this->source = Permission::get_codes(true); parent::__construct($name, $title); }
public function testGetCodesUngrouped() { $codes = Permission::get_codes(false); $this->assertArrayHasKey('SITETREE_VIEW_ALL', $codes); }