-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
103 lines (91 loc) · 2.89 KB
/
controller.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace Concrete\Package\BooleanRich;
use Concrete\Core\Attribute\Category\CategoryService;
use Concrete\Core\Config\Repository\Repository;
use Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface;
use Concrete\Core\Database\EntityManager\Provider\StandardPackageProvider;
use Concrete\Core\Package\Package;
use Gettext\Translations;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends Package implements ProviderAggregateInterface
{
protected $pkgHandle = 'boolean_rich';
protected $pkgVersion = '1.2.2';
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::$appVersionRequired
*/
protected $appVersionRequired = '8.5.2';
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::getPackageName()
*/
public function getPackageName()
{
return t('Checkbox attribute with Rich Text');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::getPackageDescription()
*/
public function getPackageDescription()
{
return t('Provide a checkbox (boolean) attribute with a rich text label.');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::install()
*/
public function install()
{
parent::install();
$this->installContentFile('config/install.xml');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::upgrade()
*/
public function upgrade()
{
parent::upgrade();
$this->installContentFile('config/install.xml');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface::getEntityManagerProvider()
*/
public function getEntityManagerProvider()
{
return new StandardPackageProvider($this->app, $this, []);
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\Package::getTranslatableStrings()
*/
public function getTranslatableStrings(Translations $translations)
{
$config = $this->app->make(Repository::class);
if (version_compare($config->get('concrete.version'), '9') < 0) {
$categoryService = $this->app->make(CategoryService::class);
foreach ($categoryService->getList() as $categoryEntity) {
$category = $categoryEntity->getAttributeKeyCategory();
foreach ($category->getList() as $key) {
if ($key->getAttributeTypeHandle() === 'boolean_rich') {
$settings = $key->getAttributeKeySettings();
$label = (string) $settings->getCheckboxLabel();
if ($label !== '') {
$translations->insert('AttributeKeyLabel', $label);
}
}
}
}
}
}
}