1 | <?php |
||
28 | * Menu builder. |
||
29 | * |
||
30 | * @author Peter Gribanov <[email protected]> |
||
31 | */ |
||
32 | class Builde |
||
33 | { |
||
34 | /** |
||
35 | * Link to guide by update the application on Windows XP. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | const GUIDE_LINK = '/guide/'; |
||
40 | |||
41 | /** |
||
42 | * @var FactoryInterface |
||
43 | */ |
||
44 | protected $factory; |
||
45 | |||
46 | /** |
||
47 | * @var RequestStack |
||
48 | */ |
||
49 | protected $request_stack; |
||
50 | |||
51 | /** |
||
52 | * @var TranslatorInterface |
||
53 | */ |
||
54 | protected $translator; |
||
55 | |||
56 | /** |
||
57 | * @var Client |
||
58 | */ |
||
59 | protected $api_client; |
||
60 | |||
61 | /** |
||
62 | * @var ChainImport |
||
63 | */ |
||
64 | protected $plugin_import; |
||
65 | |||
66 | /** |
||
67 | * @var ChainExport |
||
68 | */ |
||
69 | protected $plugin_export; |
||
70 | |||
71 | /** |
||
72 | * @var ChainSearch |
||
73 | */ |
||
74 | protected $plugin_search; |
||
75 | |||
76 | /** |
||
77 | * @var ChainFiller |
||
78 | */ |
||
79 | protected $plugin_filler; |
||
80 | |||
81 | /** |
||
82 | * @var ChainSetting |
||
83 | */ |
||
84 | protected $plugin_setting; |
||
85 | |||
86 | /** |
||
87 | * @var ChainItem |
||
88 | */ |
||
89 | protected $plugin_item; |
||
90 | |||
91 | /** |
||
92 | * @param FactoryInterface $factory |
||
93 | * @param RequestStack $request_stack |
||
94 | * @param TranslatorInterface $translator |
||
95 | * @param Client $api_client |
||
96 | * @param ChainImport $plugin_import |
||
97 | * @param ChainExport $plugin_export |
||
98 | * @param ChainSearch $plugin_search |
||
99 | * @param ChainFiller $plugin_filler |
||
100 | * @param ChainSetting $plugin_setting |
||
101 | * @param ChainItem $plugin_item |
||
102 | */ |
||
103 | public function __construct( |
||
126 | |||
127 | /** |
||
128 | * @return ItemInterface |
||
129 | */ |
||
130 | public function createMainMenu() |
||
131 | { |
||
132 | /* @var $menu ItemInterface */ |
||
133 | $menu = $this->factory |
||
134 | ->createItem('root') |
||
135 | ->setUri($this->request_stack->getMasterRequest()->getRequestUri()); |
||
136 | |||
137 | $menu |
||
138 | ->addChild('Search', ['route' => 'home_search']) |
||
139 | ->setLinkAttribute('class', 'icon-label icon-gray-search'); |
||
140 | $add = $menu |
||
141 | ->addChild('Add record') |
||
142 | ->setLabelAttribute('class', 'icon-label icon-gray-add'); |
||
143 | |||
144 | // synchronization items |
||
145 | if ($this->plugin_import->hasPlugins() || $this->plugin_export->hasPlugins()) { |
||
146 | $sync = $menu |
||
147 | ->addChild('Synchronization') |
||
148 | ->setLabelAttribute('class', 'icon-label icon-white-cloud-sync'); |
||
149 | |||
150 | // add import plugin items |
||
151 | $this->addPluginItems( |
||
152 | $this->plugin_import, |
||
153 | $sync, |
||
154 | 'Import items', |
||
155 | '', |
||
156 | 'icon-label icon-white-cloud-download' |
||
157 | ); |
||
158 | // add export plugin items |
||
159 | $this->addPluginItems( |
||
160 | $this->plugin_export, |
||
161 | $sync, |
||
162 | 'Export items', |
||
163 | '', |
||
164 | 'icon-label icon-white-cloud-arrow-up' |
||
165 | ); |
||
166 | } |
||
167 | |||
168 | $settings = $menu |
||
169 | ->addChild('Settings') |
||
170 | ->setLabelAttribute('class', 'icon-label icon-gray-settings'); |
||
171 | |||
172 | // add search plugin items |
||
173 | $this->addPluginItems( |
||
174 | $this->plugin_search, |
||
175 | $add, |
||
176 | 'Search by name', |
||
177 | 'Search by name the source of filling item', |
||
178 | 'icon-label icon-white-search' |
||
179 | ); |
||
180 | if ($this->plugin_search->hasPlugins()) { |
||
181 | $add |
||
182 | ->addChild('Search in all plugins', ['route' => 'fill_search_in_all']) |
||
183 | ->setAttribute('title', $this->translator->trans('Search by name in all plugins')) |
||
184 | ->setLinkAttribute('class', 'icon-label icon-white-cloud-search'); |
||
185 | $add |
||
186 | ->addChild('Add from URL', ['route' => 'fill_search_filler']) |
||
187 | ->setAttribute('title', $this->translator->trans('Search plugin by the URL for filling item')) |
||
188 | ->setLinkAttribute('class', 'icon-label icon-white-cloud-search'); |
||
189 | } |
||
190 | // add filler plugin items |
||
191 | $this->addPluginItems( |
||
192 | $this->plugin_filler, |
||
193 | $add, |
||
194 | 'Fill from source', |
||
195 | 'Fill record from source (example source is URL)', |
||
196 | 'icon-label icon-white-share' |
||
197 | ); |
||
198 | // add manually |
||
199 | $add |
||
200 | ->addChild('Fill manually', ['route' => 'item_add_manually']) |
||
201 | ->setLinkAttribute('class', 'icon-label icon-white-add'); |
||
202 | |||
313 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: