PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
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 1.9.2, at app/src/DataSources/Manager.php

124 lines 2.1 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 tags Manager class
40 *
41 * @return TagsManager
42 */
43 public function tagsManager(): TagsManager {
44 return \Depicter::resolve('depicter.dataSources.tags.manager');
45 }
46
47 /**
48 * Get DataSource instance by type
49 *
50 * @param string $type
51 *
52 * @return DataSourceInterface
53 */
54 public function getByType( string $type ){
55 $result = $this->posts();
56
57 switch ( $type ) {
58
59 case 'wpPost':
60 case 'wpPostHandpicked':
61 case 'wpPage':
62 case 'wpPageHandpicked':
63 case 'wpCPT':
64 $result = $this->posts();
65 break;
66
67 case 'wooProduct':
68 case 'wooProducts':
69 $result = $this->products();
70 break;
71
72 case 'wooHandpicked':
73 $result = $this->handPickedProducts();
74 break;
75
76 case 'catalogs':
77 $result = \Depicter::resolve('depicter.dataSources.catalogs');
78 break;
79
80 default:
81 break;
82 }
83
84 return $result;
85 }
86
87 /**
88 * Get post type by DataSource type
89 *
90 * @param string $type
91 *
92 * @return string
93 */
94 public function getPostTypeByType( string $type ){
95 $result = '';
96
97 switch ( $type ) {
98
99 case 'wpPost':
100 case 'wpPostHandpicked':
101 case 'wpCPT':
102 $result = 'post';
103 break;
104
105 case 'wpPage':
106 case 'wpPageHandpicked':
107 $result = 'page';
108 break;
109
110 case 'wooProduct':
111 case 'wooProducts':
112 case 'wooHandpicked':
113 $result = 'product';
114 break;
115
116 default:
117 break;
118 }
119
120 return $result;
121 }
122
123 }
124