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 / Catalogs.php

Catalogs.php in Depicter — Popup & Slider Builder 1.9.2, at app/src/DataSources/Catalogs.php

89 lines 1.7 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
5 use Averta\Core\Utility\Arr;
6 use Averta\WordPress\Utility\JSON;
7
8 /**
9 * DataSource which holds pre-defined content for replacement in document
10 */
11 class Catalogs extends DataSourceBase implements DataSourceInterface
12 {
13 /**
14 * DataSource name
15 *
16 * @var string
17 */
18 protected $type = 'catalogs';
19
20 /**
21 * DataSource properties
22 *
23 * @var array
24 */
25 protected $properties = [];
26
27 /**
28 * Default input params for retrieving dataSource records
29 *
30 * @var array
31 */
32 protected $defaultInputParams = [];
33
34 /**
35 * Asset groups of this DataSource
36 *
37 * @var array
38 */
39 protected $assetGroupNames = [ 'catalog' ];
40
41 /**
42 * Retrieves the list of records based on query params
43 *
44 * @param $args
45 *
46 * @return array
47 */
48 protected function getRecords( $args ){
49 return $args['catalogs'] ?? [];
50 }
51
52 public function previewRecords( array $args = [] ) {
53 $args = $this->prepare( $args );
54 return $this->getRecords( $args );
55 }
56
57 /**
58 * Get list of datasheets and corresponding required arguments
59 *
60 * @param array $args
61 *
62 * @return array
63 */
64 public function getDataSheetArgs( array $args = [] ){
65 // convert array of objects to associate array
66 $sheets = $this->getRecords( $args );
67 return JSON::decode( JSON::encode( $sheets ), true );
68 }
69
70 /**
71 * Get list of asset groups for this dataSource
72 *
73 * @param $args
74 *
75 * @return array
76 */
77 public function getAssets( $args ){
78 $assetGroupNames = $this->getAssetGroupNames();
79
80 $groups = [];
81 foreach( $assetGroupNames as $assetGroupName ){
82 $groups[ $assetGroupName ] = $args;
83 }
84
85 return \Depicter::dataSource()->tagsManager()->getAssetsInGroups( $groups );
86 }
87
88 }
89