Commit | Line | Data |
---|---|---|
75e0d7eb | 1 | <?php |
a9229942 | 2 | |
75e0d7eb | 3 | namespace wcf\data; |
4 | ||
5 | /** | |
6 | * Default implementation of the `IToggleAction` interface. | |
75e0d7eb | 7 | * |
a9229942 TD |
8 | * @author Florian Gail |
9 | * @copyright 2001-2019 WoltLab GmbH | |
10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
11 | * @package WoltLabSuite\Core\Data | |
12 | * @since 5.2 | |
13 | * | |
14 | * @mixin AbstractDatabaseObjectAction | |
75e0d7eb | 15 | */ |
a9229942 TD |
16 | trait TDatabaseObjectToggle |
17 | { | |
18 | /** | |
19 | * Validates the "toggle" action. | |
20 | */ | |
21 | public function validateToggle() | |
22 | { | |
23 | $this->validateUpdate(); | |
24 | } | |
25 | ||
26 | /** | |
27 | * Toggles the "isDisabled" status of the relevant objects. | |
28 | */ | |
29 | public function toggle() | |
30 | { | |
31 | foreach ($this->getObjects() as $object) { | |
32 | $object->update([ | |
33 | 'isDisabled' => $object->isDisabled ? 0 : 1, | |
34 | ]); | |
35 | } | |
36 | } | |
75e0d7eb | 37 | } |