Merge branch '6.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / TDatabaseObjectToggle.class.php
1 <?php
2
3 namespace wcf\data;
4
5 /**
6 * Default implementation of the `IToggleAction` interface.
7 *
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 * @since 5.2
12 *
13 * @mixin AbstractDatabaseObjectAction
14 */
15 trait TDatabaseObjectToggle
16 {
17 /**
18 * Validates the "toggle" action.
19 */
20 public function validateToggle()
21 {
22 $this->validateUpdate();
23 }
24
25 /**
26 * Toggles the "isDisabled" status of the relevant objects.
27 */
28 public function toggle()
29 {
30 foreach ($this->getObjects() as $object) {
31 $object->update([
32 'isDisabled' => $object->isDisabled ? 0 : 1,
33 ]);
34 }
35 }
36 }