3 namespace BookStack\Activity;
5 use BookStack\Entities\Models\Bookshelf;
6 use BookStack\Entities\Models\Entity;
7 use BookStack\Entities\Models\Page;
12 * Default level, No specific option set
13 * Typically not a stored status
18 * Ignore all notifications.
23 * Watch for new content.
28 * Watch for updates and new content
33 * Watch for comments, updates and new content.
38 * Get all the possible values as an option_name => value array.
39 * @returns array<string, int>
41 public static function all(): array
44 foreach ((new \ReflectionClass(static::class))->getConstants() as $name => $value) {
45 $options[strtolower($name)] = $value;
52 * Get the watch options suited for the given entity.
53 * @returns array<string, int>
55 public static function allSuitedFor(Entity $entity): array
57 $options = static::all();
59 if ($entity instanceof Page) {
60 unset($options['new']);
61 } elseif ($entity instanceof Bookshelf) {
69 * Convert the given name to a level value.
70 * Defaults to default value if the level does not exist.
72 public static function levelNameToValue(string $level): int
74 return static::all()[$level] ?? static::DEFAULT;
78 * Convert the given int level value to a level name.
79 * Defaults to 'default' level name if not existing.
81 public static function levelValueToName(int $level): string
83 foreach (static::all() as $name => $value) {
84 if ($level === $value) {