.. include:: /Includes.rst.txt .. _BitSet: ================== How To Use BitSets ================== To efficiently handle boolean flags, bit sets can be used since TYPO3 v10. Class :php:`\TYPO3\CMS\Core\Type\BitSet` provides a TYPO3 implementation of a :php:`BitSet`. It can be used standalone and accessed from the outside, but we recommend creating specific :php:`BitSet` classes that extend the TYPO3 :php:`BitSet` class. The functionality is best described by an example: :: get(PERMISSIONS_PAGE_SHOW); // true $bitSet->get(PERMISSIONS_CONTENT_EDIT); // false This is directly using the TYPO3 Core class. Implementing that via an extending class makes it clearer and easier to use: :: get($permission); } /** * @return bool */ public function hasAllPermissions(): bool { return $this->get(static::ALL); } /** * @param int $permission */ public function allow(int $permission): void { $this->set($permission); } } $permissions = new Permissions(Permissions::PAGE_SHOW | Permissions::PAGE_NEW); $permissions->hasPermission(Permissions::PAGE_SHOW); // true $permissions->hasPermission(Permissions::CONTENT_EDIT); // false