PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.6
Responsive Menu – Create Mobile-Friendly Menu v3.0.6
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / src / app / Services / OptionService.php

OptionService.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.6, at src/app/Services/OptionService.php

60 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Services;
4 use ResponsiveMenu\Repositories\OptionRepository as OptionRepository;
5 use ResponsiveMenu\WPML\WPML as WPML;
6 use ResponsiveMenu\Factories\AdminSaveFactory as SaveFactory;
7 use ResponsiveMenu\Factories\OptionFactory as OptionFactory;
8 use ResponsiveMenu\Collections\OptionsCollection as OptionsCollection;
9
10 class OptionService {
11
12 public function __construct(OptionRepository $repository, OptionFactory $factory) {
13 $this->repository = $repository;
14 $this->factory = $factory;
15 }
16
17 public function updateOptions(array $options) {
18
19 foreach($options as $key => $val)
20 $this->repository->update($this->factory->build($key, $val));
21
22 $options = $this->all();
23
24 $this->updateWpml($options);
25 $this->buildFiles($options);
26
27 return $options;
28 }
29
30 public function createOptions(array $options) {
31
32 foreach($options as $key => $val)
33 $this->repository->create($this->factory->build($key, $val));
34
35 $options = $this->all();
36
37 $this->updateWpml($options);
38 $this->buildFiles($options);
39
40 return $options;
41 }
42
43 public function all() {
44 return $this->repository->all();
45 }
46
47 public function updateWpml(OptionsCollection $options) {
48 $wpml = new WPML;
49 $wpml->saveFromOptions($options);
50 }
51
52 public function buildFiles(OptionsCollection $options) {
53 if($options['external_files'] == 'on'):
54 $save_factory = new SaveFactory();
55 $save_factory->build($options);
56 endif;
57 }
58
59 }
60