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
← All changes | app/src/DataSources/Manager.php +80 -17 1.2.01.9.2 View file →
@@ -1,7 +1,9 @@
1 1 <?php
2 2 namespace Depicter\DataSources;
3 3
4 +use Depicter\DataSources\Tags\Manager as TagsManager;
5 +
4 6 /**
5 7 * Chained api to access all data sources
6 8 */
7 9 class Manager {
@@ -10,10 +12,9 @@
10 12 * Returns the instance of posts class
11 13 *
12 14 * @return Posts
13 15 */
14 - public function posts()
15 - {
16 + public function posts(): Posts {
16 17 return \Depicter::resolve('depicter.dataSources.posts');
17 18 }
18 19
19 20 /**
@@ -20,41 +21,103 @@
20 21 * Returns the instance of products class
21 22 *
22 23 * @return Products
23 24 */
24 - public function products()
25 - {
25 + public function products(): Products {
26 26 return \Depicter::resolve('depicter.dataSources.products');
27 27 }
28 28
29 29 /**
30 - * Returns the instance of hand picked products class
30 + * Returns the instance of handpicked products class
31 31 *
32 32 * @return HandPickedProducts
33 33 */
34 - public function handPickedProducts()
35 - {
34 + public function handPickedProducts(): HandPickedProducts {
36 35 return \Depicter::resolve('depicter.dataSources.handPickedProducts');
37 36 }
38 37
39 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 + *
40 50 * @param string $type
41 51 *
42 - * @return Posts|Products|HandPickedProducts|bool
52 + * @return DataSourceInterface
43 53 */
44 - public function getByType( $type ){
45 - if( 'wpPost' === $type || 'wpPage' === $type ){
46 - return $this->posts();
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;
47 82 }
48 83
49 - if( 'wooProducts' === $type ){
50 - return $this->products();
51 - }
84 + return $result;
85 + }
52 86
53 - if( 'wooHandpicks' === $type ){
54 - return $this->handPickedProducts();
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;
55 118 }
56 119
57 - return false;
120 + return $result;
58 121 }
59 122
60 123 }