public function addObject($item) { if ($item instanceof User && $this->type != self::USERS) { GitoliteException::throwWrongTeamType($item->name, self::USERS); } elseif ($item instanceof Repo && $this->type != self::REPO) { GitoliteException::throwWrongTeamType($item->name, self::REPO); } $item->addTeam($this); $this->items[] = $item; }
/** * @param $name * @param $type * @param $class * * @return Team * @throws GitoliteException */ public function getTeamAs($name, $type, $class) { /** * @var Object $object */ if ($team = $this->getTeam($name)) { if ($team->type && $team->type != $type) { GitoliteException::throwWrongTeamType($name, $type); } if (!$team->type) { $arr = []; foreach ($team->items as $item) { $object = new $class(); $object->teams = $item->teams; $object->name = $item->name; $arr[] = $object; } $team->items = $arr; $team->type = $type; } } return $team; }
/** * Add Team * * @param Team $team A team object * * @return Acl */ public function addTeam(Team $team) { if ($team->type != Team::USERS) { GitoliteException::throwWrongTeamType($team, Team::USERS); } foreach ($team->items as $item) { $this->addUser($item); } return $this; }