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

120 lines 2.0 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 default:
77 break;
78 }
79
80 return $result;
81 }
82
83 /**
84 * Get post type by DataSource type
85 *
86 * @param string $type
87 *
88 * @return string
89 */
90 public function getPostTypeByType( string $type ){
91 $result = '';
92
93 switch ( $type ) {
94
95 case 'wpPost':
96 case 'wpPostHandpicked':
97 case 'wpCPT':
98 $result = 'post';
99 break;
100
101 case 'wpPage':
102 case 'wpPageHandpicked':
103 $result = 'page';
104 break;
105
106 case 'wooProduct':
107 case 'wooProducts':
108 case 'wooHandpicked':
109 $result = 'product';
110 break;
111
112 default:
113 break;
114 }
115
116 return $result;
117 }
118
119 }
120