Split additional joins into multiple lines
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / cache / builder / CategoryCacheBuilder.class.php
1 <?php
2
3 namespace wcf\system\cache\builder;
4
5 use wcf\data\category\CategoryList;
6
7 /**
8 * Caches the categories for the active application.
9 *
10 * @author Matthias Schmidt
11 * @copyright 2001-2019 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\Cache\Builder
14 */
15 class CategoryCacheBuilder extends AbstractCacheBuilder
16 {
17 /**
18 * @inheritDoc
19 */
20 public function rebuild(array $parameters)
21 {
22 $list = new CategoryList();
23 $list->sqlSelects = "object_type.objectType";
24 $list->sqlJoins = "
25 LEFT JOIN wcf" . WCF_N . "_object_type object_type
26 ON object_type.objectTypeID = category.objectTypeID";
27 $list->sqlOrderBy = "category.showOrder ASC";
28 $list->readObjects();
29
30 $data = [
31 'categories' => $list->getObjects(),
32 'objectTypeCategoryIDs' => [],
33 ];
34 foreach ($list as $category) {
35 /** @noinspection PhpUndefinedFieldInspection */
36 $objectType = $category->objectType;
37
38 if (!isset($data['objectTypeCategoryIDs'][$objectType])) {
39 $data['objectTypeCategoryIDs'][$objectType] = [];
40 }
41
42 $data['objectTypeCategoryIDs'][$objectType][] = $category->categoryID;
43 }
44
45 return $data;
46 }
47 }