Add EmailLogListPage
[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 * @package WoltLabSuite\Core\Data
12 * @since 5.2
13 *
14 * @mixin AbstractDatabaseObjectAction
15 */
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 }
37 }