@@ 23-85 (lines=63) @@ | ||
20 | * @author Mike Nelson |
|
21 | * @since $VID:$ |
|
22 | */ |
|
23 | class PersonalDataEraserManager |
|
24 | { |
|
25 | ||
26 | public function __construct() |
|
27 | { |
|
28 | add_filter( |
|
29 | 'wp_privacy_personal_data_erasers', |
|
30 | array($this, 'hookInErasers') |
|
31 | ); |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * For all the registered `PrivateDataEraserInterface`s, add them as erasers |
|
37 | */ |
|
38 | public function hookInErasers($erasers) |
|
39 | { |
|
40 | // load all the privacy policy stuff |
|
41 | // add post policy text |
|
42 | foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
|
43 | $erasers[ get_class($eraser) ] = array( |
|
44 | 'eraser_friendly_name' => $eraser->name(), |
|
45 | 'callback' => array($eraser, 'erase'), |
|
46 | ); |
|
47 | } |
|
48 | return $erasers; |
|
49 | } |
|
50 | ||
51 | ||
52 | /** |
|
53 | * @return CollectionInterface|PersonalDataEraserInterface[] |
|
54 | * @throws InvalidIdentifierException |
|
55 | * @throws InvalidInterfaceException |
|
56 | * @throws InvalidFilePathException |
|
57 | * @throws InvalidEntityException |
|
58 | * @throws InvalidDataTypeException |
|
59 | * @throws InvalidClassException |
|
60 | */ |
|
61 | protected function loadPrivateDataEraserCollection() |
|
62 | { |
|
63 | $loader = new CollectionLoader( |
|
64 | new CollectionDetails( |
|
65 | // collection name |
|
66 | 'privacy_erasers', |
|
67 | // collection interface |
|
68 | 'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
|
69 | // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
70 | apply_filters( |
|
71 | 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
72 | array('EventEspresso\core\domain\services\admin\privacy\erasure') |
|
73 | ), |
|
74 | // filepaths to classes to add |
|
75 | array(), |
|
76 | // file mask to use if parsing folder for files to add |
|
77 | '', |
|
78 | // what to use as identifier for collection entities |
|
79 | // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | CollectionDetails::ID_CLASS_NAME |
|
81 | ) |
|
82 | ); |
|
83 | return $loader->getCollection(); |
|
84 | } |
|
85 | } |
|
86 | // End of file PersonalDataEraserManager.php |
|
87 | // Location: EventEspresso\core\domain\services\admin/PersonalDataEraserManager.php |
|
88 |
@@ 23-87 (lines=65) @@ | ||
20 | * @author Mike Nelson |
|
21 | * @since $VID:$ |
|
22 | */ |
|
23 | class PersonalDataExporterManager |
|
24 | { |
|
25 | ||
26 | public function __construct() |
|
27 | { |
|
28 | add_filter( |
|
29 | 'wp_privacy_personal_data_exporters', |
|
30 | array($this, 'hookInExporters') |
|
31 | ); |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Adds EE's exporters to the list of WP exporters |
|
37 | * |
|
38 | * @param array $exporters |
|
39 | * @return array |
|
40 | */ |
|
41 | public function hookInExporters($exporters) |
|
42 | { |
|
43 | // load all the privacy policy stuff |
|
44 | // add post policy text |
|
45 | foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
|
46 | $exporters[ get_class($exporter) ] = array( |
|
47 | 'exporter_friendly_name' => $exporter->name(), |
|
48 | 'callback' => array($exporter, 'export'), |
|
49 | ); |
|
50 | } |
|
51 | return $exporters; |
|
52 | } |
|
53 | ||
54 | ||
55 | /** |
|
56 | * @return CollectionInterface|PersonalDataExporterInterface[] |
|
57 | * @throws InvalidIdentifierException |
|
58 | * @throws InvalidInterfaceException |
|
59 | * @throws InvalidFilePathException |
|
60 | * @throws InvalidEntityException |
|
61 | * @throws InvalidDataTypeException |
|
62 | * @throws InvalidClassException |
|
63 | */ |
|
64 | protected function loadPrivateDataExporterCollection() |
|
65 | { |
|
66 | $loader = new CollectionLoader( |
|
67 | new CollectionDetails( |
|
68 | // collection name |
|
69 | 'personal_data_exporters', |
|
70 | // collection interface |
|
71 | 'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface', |
|
72 | // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
73 | apply_filters( |
|
74 | 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
75 | array('EventEspresso\core\domain\services\admin\privacy\export') |
|
76 | ), |
|
77 | // filepaths to classes to add |
|
78 | array(), |
|
79 | // file mask to use if parsing folder for files to add |
|
80 | '', |
|
81 | // what to use as identifier for collection entities |
|
82 | // using CLASS NAME prevents duplicates (works like a singleton) |
|
83 | CollectionDetails::ID_CLASS_NAME |
|
84 | ) |
|
85 | ); |
|
86 | return $loader->getCollection(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | // End of file PersonalDataExporterManager.php |