xref: /plugin/structpublish/meta/Constants.php (revision 2cd86f5fad8f5947eca47fa65c1b02d66da62187)
1<?php
2
3namespace dokuwiki\plugin\structpublish\meta;
4
5/**
6 * Defines some constants used throughout the plugin
7 *
8 * @todo this might need to be replaced later if we want to have user configurable status
9 */
10class Constants
11{
12    // a page can be in one current status
13    const STATUS_DRAFT = 'draft';
14    const STATUS_APPROVED = 'approved';
15    const STATUS_PUBLISHED = 'published';
16
17    // an action transitions a page from one status to another
18    const ACTION_APPROVE = 'approve';
19    const ACTION_PUBLISH = 'publish';
20
21
22    /**
23     * Convenience function mapping transition actions to resulting status
24     *
25     * @param string $action
26     * @return string
27     */
28    public static function transitionBy($action)
29    {
30        $map = [
31            self::ACTION_APPROVE => self::STATUS_APPROVED,
32            self::ACTION_PUBLISH => self::STATUS_PUBLISHED,
33        ];
34
35        return $map[$action];
36    }
37}
38