PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / DataSources / Manager.php

Manager.php in Depicter — Popup & Slider Builder trunk, at app/src/DataSources/Manager.php

137 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\DataSources;
3
4 use Depicter\DataSources\Tags\Manager as TagsManager;
5
6 /**
7 * Chained api to access all data sources
8 */
9 class Manager {
10
11 /**
12 * Returns the instance of posts class
13 *
14 * @return Posts
15 */
16 public function posts(): Posts {
17 return \Depicter::resolve('depicter.dataSources.posts');
18 }
19
20 /**
21 * Returns the instance of products class
22 *
23 * @return Products
24 */
25 public function products(): Products {
26 return \Depicter::resolve('depicter.dataSources.products');
27 }
28
29 /**
30 * Returns the instance of handpicked products class
31 *
32 * @return HandPickedProducts
33 */
34 public function handPickedProducts(): HandPickedProducts {
35 return \Depicter::resolve('depicter.dataSources.handPickedProducts');
36 }
37
38 /**
39 * Returns the instance of GooglePlacesReview class
40 *
41 * @return GooglePlaces
42 */
43 public function googlePlaces(): GooglePlaces {
44 return \Depicter::resolve('depicter.dataSources.google.places');
45 }
46
47 /**
48 * Returns the instance of tags Manager class
49 *
50 * @return TagsManager
51 */
52 public function tagsManager(): TagsManager {
53 return \Depicter::resolve('depicter.dataSources.tags.manager');
54 }
55
56 /**
57 * Get DataSource instance by type
58 *
59 * @param string $type
60 *
61 * @return DataSourceInterface
62 */
63 public function getByType( string $type ){
64 $result = $this->posts();
65
66 switch ( $type ) {
67
68 case 'wpPost':
69 case 'wpPostHandpicked':
70 case 'wpPage':
71 case 'wpPageHandpicked':
72 case 'wpCPT':
73 $result = $this->posts();
74 break;
75
76 case 'wooProduct':
77 case 'wooProducts':
78 $result = $this->products();
79 break;
80
81 case 'wooHandpicked':
82 $result = $this->handPickedProducts();
83 break;
84
85 case 'googlePlaceReview':
86 $result = $this->googlePlaces();
87 break;
88
89 case 'catalogs':
90 $result = \Depicter::resolve('depicter.dataSources.catalogs');
91 break;
92
93 default:
94 break;
95 }
96
97 return $result;
98 }
99
100 /**
101 * Get post type by DataSource type
102 *
103 * @param string $type
104 *
105 * @return string
106 */
107 public function getPostTypeByType( string $type ){
108 $result = '';
109
110 switch ( $type ) {
111
112 case 'wpPost':
113 case 'wpPostHandpicked':
114 case 'wpCPT':
115 $result = 'post';
116 break;
117
118 case 'wpPage':
119 case 'wpPageHandpicked':
120 $result = 'page';
121 break;
122
123 case 'wooProduct':
124 case 'wooProducts':
125 case 'wooHandpicked':
126 $result = 'product';
127 break;
128
129 default:
130 break;
131 }
132
133 return $result;
134 }
135
136 }
137