Split additional joins into multiple lines
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / template / TemplateList.class.php
1 <?php
2
3 namespace wcf\data\template;
4
5 use wcf\data\DatabaseObjectList;
6 use wcf\data\package\PackageCache;
7 use wcf\system\application\ApplicationHandler;
8
9 /**
10 * Represents a list of templates.
11 *
12 * @author Alexander Ebert
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\Data\Template
16 *
17 * @method Template current()
18 * @method Template[] getObjects()
19 * @method Template|null search($objectID)
20 * @property Template[] $objects
21 */
22 class TemplateList extends DatabaseObjectList
23 {
24 /**
25 * @inheritDoc
26 */
27 public $className = Template::class;
28
29 /**
30 * Creates a new TemplateList object.
31 */
32 public function __construct()
33 {
34 parent::__construct();
35
36 $this->sqlSelects = 'package.package, template_group.templateGroupFolderName';
37 $this->sqlJoins = "
38 LEFT JOIN wcf" . WCF_N . "_package package
39 ON package.packageID = template.packageID
40 LEFT JOIN wcf" . WCF_N . "_template_group template_group
41 ON template_group.templateGroupID = template.templateGroupID";
42 }
43
44 /**
45 * @inheritDoc
46 */
47 public function readObjects()
48 {
49 parent::readObjects();
50
51 foreach ($this->objects as $template) {
52 if ($template->application != 'wcf') {
53 $application = ApplicationHandler::getInstance()->getApplication($template->application);
54 } else {
55 $application = ApplicationHandler::getInstance()->getWCF();
56 }
57 $package = PackageCache::getInstance()->getPackage($application->packageID);
58
59 // set directory of the application package the template
60 // belongs to
61 $template->packageDir = $package->packageDir;
62 }
63 }
64 }