1<?php namespace ILIAS\GlobalScreen\Scope\MainMenu\Factory;
2
3use ILIAS\GlobalScreen\Identification\IdentificationInterface;
4use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\Complex;
5use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\Link;
6use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\LinkList;
7use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\Lost;
8use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\RepositoryLink;
9use ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item\Separator;
10use ILIAS\GlobalScreen\Scope\MainMenu\Factory\TopItem\TopLinkItem;
11use ILIAS\GlobalScreen\Scope\MainMenu\Factory\TopItem\TopParentItem;
12
13/**
14 * Class MainMenuItemFactory
15 *
16 * This factory provides you all available types for MainMenu GlobalScreen Items.
17 *
18 * @author Fabian Schmid <fs@studer-raimann.ch>
19 */
20class MainMenuItemFactory
21{
22
23    /**
24     * Returns you a GlobalScreen TopParentItem which can be added to the MainMenu. TopItems are
25     * always at the first level in the MainMenu and can contain other
26     * entries (e.g. Links).
27     *
28     *
29     * @param IdentificationInterface $identification
30     *
31     * @return TopParentItem
32     */
33    public function topParentItem(IdentificationInterface $identification) : TopParentItem
34    {
35        return new TopParentItem($identification);
36    }
37
38
39    /**
40     * Returns you a GlobalScreen TopLinkItem which can be added to the MainMenu. TopLinkItem are
41     * always at the first level in the MainMenu and have an action
42     *
43     * @param IdentificationInterface $identification
44     *
45     * @return TopLinkItem
46     */
47    public function topLinkItem(IdentificationInterface $identification) : TopLinkItem
48    {
49        return new TopLinkItem($identification);
50    }
51
52
53    /**
54     * Returns you s GlobalScreen Link which can be added to Slates.
55     *
56     * @param IdentificationInterface $identification
57     *
58     * @return Link
59     */
60    public function link(IdentificationInterface $identification) : Link
61    {
62        return new Link($identification);
63    }
64
65
66    /**
67     * Returns you a GlobalScreen Separator which is used to separate to other entries in a
68     * optical way.
69     *
70     * @param IdentificationInterface $identification
71     *
72     * @return Separator
73     */
74    public function separator(IdentificationInterface $identification) : Separator
75    {
76        return new Separator($identification);
77    }
78
79
80    /**
81     * Returns you a GlobalScreen Complex Item which is used to generate complex
82     * content from a Async-URL
83     *
84     * @param IdentificationInterface $identification
85     *
86     * @return Complex
87     */
88    public function complex(IdentificationInterface $identification) : Complex
89    {
90        return new Complex($identification);
91    }
92
93
94    /**
95     * Returns you a GlobalScreen RepositoryLink Item which is used to generate URLs to Ref-IDs
96     *
97     * @param IdentificationInterface $identification
98     *
99     * @return RepositoryLink
100     */
101    public function repositoryLink(IdentificationInterface $identification) : RepositoryLink
102    {
103        return new RepositoryLink($identification);
104    }
105
106
107    /**
108     * Returns you a GlobalScreen LinkList Item which is used to group multiple Links
109     *
110     * @param IdentificationInterface $identification
111     *
112     * @return LinkList
113     */
114    public function linkList(IdentificationInterface $identification) : LinkList
115    {
116        return new LinkList($identification);
117    }
118
119
120    /**
121     * @param string                  $class_name
122     * @param IdentificationInterface $identification
123     *
124     * @return isItem
125     */
126    public function custom(string $class_name, IdentificationInterface $identification) : isItem
127    {
128        if (!class_exists($class_name)) {
129            return new Lost($identification);
130        }
131
132        return new $class_name($identification);
133    }
134}
135