-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathextension.driver.php
76 lines (59 loc) · 2.08 KB
/
extension.driver.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once EXTENSIONS . '/remote_datasource/data-sources/datasource.remote.php';
class Extension_Remote_Datasource extends Extension
{
protected static $provides = array();
public static function registerProviders()
{
self::$provides = array(
'data-sources' => array(
'RemoteDatasource' => RemoteDatasource::getName()
)
);
return true;
}
public static function providerOf($type = null)
{
self::registerProviders();
if (is_null($type)) {
return self::$provides;
}
if (!isset(self::$provides[$type])) {
return array();
}
return self::$provides[$type];
}
public function getSubscribedDelegates()
{
return array(
array(
'page' => '/system/preferences/',
'delegate' => 'AddCachingOpportunity',
'callback' => 'addCachingOpportunity'
)
);
}
public function addCachingOpportunity($context)
{
$current_cache = Symphony::Configuration()->get('remotedatasource', 'caching');
$label = Widget::Label(__('Remote Datasource'));
$options = array();
foreach ($context['available_caches'] as $handle => $cache_name) {
$options[] = array($handle, ($current_cache == $handle || (!isset($current_cache) && $handle === 'database')), $cache_name);
}
$select = Widget::Select('settings[caching][remotedatasource]', $options, array('class' => 'picker'));
$label->appendChild($select);
$context['wrapper']->appendChild($label);
}
public function install()
{
Symphony::Configuration()->set('csv-delimiter', ',', 'remote_datasource');
Symphony::Configuration()->set('csv-enclosure', '"', 'remote_datasource');
Symphony::Configuration()->set('csv-escape', '\\', 'remote_datasource');
Symphony::Configuration()->write();
}
public function uninstall()
{
Symphony::Configuration()->remove('remote_datasource');
}
}