Major overhaul of caching system (work in progress)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / cache / builder / ObjectTypeCacheBuilder.class.php
1 <?php
2 namespace wcf\system\cache\builder;
3 use wcf\data\object\type\definition\ObjectTypeDefinition;
4 use wcf\data\object\type\ObjectType;
5 use wcf\system\WCF;
6
7 /**
8 * Caches object types and object type definitions.
9 *
10 * @author Marcel Werk
11 * @copyright 2001-2013 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.cache.builder
15 * @category Community Framework
16 */
17 class ObjectTypeCacheBuilder extends AbstractCacheBuilder {
18 /**
19 * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
20 */
21 public function rebuild(array $parameters) {
22 $data = array(
23 'categories' => array(),
24 'definitions' => array(),
25 'objectTypes' => array()
26 );
27
28 // get definitions
29 $sql = "SELECT *
30 FROM wcf".WCF_N."_object_type_definition";
31 $statement = WCF::getDB()->prepareStatement($sql);
32 $statement->execute();
33 while ($row = $statement->fetchArray()) {
34 $data['definitions'][$row['definitionID']] = new ObjectTypeDefinition(null, $row);
35
36 if ($row['categoryName']) {
37 if (!isset($data['categories'][$row['categoryName']])) {
38 $data['categories'][$row['categoryName']] = array();
39 }
40
41 $data['categories'][$row['categoryName']][] = $row['definitionID'];
42 }
43 }
44
45 // get object types
46 $sql = "SELECT *
47 FROM wcf".WCF_N."_object_type object_type";
48 $statement = WCF::getDB()->prepareStatement($sql);
49 $statement->execute();
50 while ($row = $statement->fetchArray()) {
51 $data['objectTypes'][$row['objectTypeID']] = new ObjectType(null, $row);
52 }
53
54 return $data;
55 }
56 }