Major overhaul of caching system (work in progress)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / cache / builder / UserGroupCacheBuilder.class.php
1 <?php
2 namespace wcf\system\cache\builder;
3 use wcf\data\user\group\UserGroupList;
4
5 /**
6 * Caches all user groups.
7 *
8 * @author Marcel Werk
9 * @copyright 2001-2013 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage system.cache.builder
13 * @category Community Framework
14 */
15 class UserGroupCacheBuilder extends AbstractCacheBuilder {
16 /**
17 * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
18 */
19 public function rebuild(array $parameters) {
20 $data = array(
21 'types' => array(),
22 'groups' => array()
23 );
24
25 // get all user groups
26 $groupList = new UserGroupList();
27 $groupList->readObjects();
28 $groups = $groupList->getObjects();
29
30 foreach ($groups as $group) {
31 if (!isset($data['types'][$group->groupType])) {
32 $data['types'][$group->groupType] = array();
33 }
34
35 $data['types'][$group->groupType][] = $group->groupID;
36 $data['groups'][$group->groupID] = $group;
37 }
38
39 return $data;
40 }
41 }