-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
43 lines (34 loc) · 1.34 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace LocalMediaIngester;
use Omeka\Module\AbstractModule;
class Module extends AbstractModule
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getConfigForm($renderer)
{
$formElementManager = $this->getServiceLocator()->get('FormElementManager');
$settings = $this->getServiceLocator()->get('Omeka\Settings');
$form = $formElementManager->get('LocalMediaIngester\Form\ConfigForm');
$form->setData([
'original_file_action' => $settings->get('localmediaingester_original_file_action', 'keep'),
]);
return $renderer->formCollection($form, false);
}
public function handleConfigForm($controller)
{
$formElementManager = $this->getServiceLocator()->get('FormElementManager');
$settings = $this->getServiceLocator()->get('Omeka\Settings');
$form = $formElementManager->get('LocalMediaIngester\Form\ConfigForm');
$form->setData($controller->params()->fromPost());
if (!$form->isValid()) {
$controller->messenger()->addErrors($form->getMessages());
return false;
}
$formData = $form->getData();
$settings->set('localmediaingester_original_file_action', $formData['original_file_action']);
return true;
}
}