Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / bbcode / attribute / BBCodeAttribute.class.php
1 <?php
2
3 namespace wcf\data\bbcode\attribute;
4
5 use wcf\data\bbcode\BBCode;
6 use wcf\data\DatabaseObject;
7
8 /**
9 * Represents a bbcode attribute.
10 *
11 * @author Tim Duesterhus, Alexander Ebert
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\Data\Bbcode\Attribute
15 *
16 * @property-read int $attributeID unique id of the bbcode attribute
17 * @property-read int $bbcodeID id of the bbcode the attribute belongs to
18 * @property-read int $attributeNo number of bbcode attribute
19 * @property-read string $attributeHtml html code used to render the bbcode attribute or empty if no such html code exists
20 * @property-read string $validationPattern regular expression used to validate the bbcode attribute's value or empty if no such regular expression exists
21 * @property-read int $required is `1` if the bbcode attribute is required of the bbcode, otherwise `0`
22 * @property-read int $useText is `1` if the bbcode's content will be used as the bbcode attribute value
23 */
24 class BBCodeAttribute extends DatabaseObject
25 {
26 /**
27 * @inheritDoc
28 */
29 protected static $databaseTableName = 'bbcode_attribute';
30
31 /**
32 * Reads attributes by assigned bbcode.
33 *
34 * @param BBCode $bbcode
35 * @return BBCodeAttribute[]
36 */
37 public static function getAttributesByBBCode(BBCode $bbcode)
38 {
39 $attributeList = new BBCodeAttributeList();
40 $attributeList->sqlOrderBy = "bbcode_attribute.attributeNo ASC";
41 $attributeList->getConditionBuilder()->add('bbcode_attribute.bbcodeID = ?', [$bbcode->bbcodeID]);
42 $attributeList->readObjects();
43
44 return $attributeList->getObjects();
45 }
46 }