Class ilMailTemplateContextService.
More...
◆ clearFromXml()
static ilMailTemplateContextService::clearFromXml |
( |
string |
$a_component, |
|
|
array |
$a_new_templates |
|
) |
| |
|
static |
- Parameters
-
string | $a_component | |
| string[] | $a_new_templates |
Definition at line 30 of file class.ilMailTemplateContextService.php.
References $DIC, $id, and $query.
Referenced by ilMailTemplateContextDefinitionProcessor\endTag().
33 if (!$DIC->database()->tableExists(
'mail_tpl_ctx')) {
36 $persisted_templates = [];
37 $query =
'SELECT id FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote($a_component,
'text');
38 $set = $DIC->database()->query(
$query);
39 while ($row = $DIC->database()->fetchAssoc($set)) {
40 $persisted_templates[] = $row[
'id'];
43 if (count($persisted_templates)) {
44 if (count($a_new_templates)) {
45 foreach ($persisted_templates as
$id) {
46 if (!in_array($id, $a_new_templates,
true)) {
47 $DIC->database()->manipulate(
48 'DELETE FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote(
51 ) .
' AND id = ' . $DIC->database()->quote($id,
'text')
56 $DIC->database()->manipulate(
57 'DELETE FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote(
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ createEntry()
static ilMailTemplateContextService::createEntry |
( |
ilMailTemplateContext |
$a_context, |
|
|
string |
$a_component, |
|
|
string |
$a_class, |
|
|
?string |
$a_path |
|
) |
| |
|
staticprotected |
Definition at line 153 of file class.ilMailTemplateContextService.php.
References $DIC, $query, $res, and ilMailTemplateContext\getId().
161 $query =
"SELECT id FROM mail_tpl_ctx WHERE id = %s";
162 $res = $DIC->database()->queryF(
$query, [
'text'], [$a_context->
getId()]);
163 $row = $DIC->database()->fetchAssoc(
$res);
164 $row_id = $row[
'id'] ?? null;
165 $context_exists = ($row_id === $a_context->
getId());
167 if (!$context_exists) {
168 $DIC->database()->insert(
'mail_tpl_ctx', [
169 'id' => [
'text', $a_context->
getId()],
170 'component' => [
'text', $a_component],
171 'class' => [
'text', $a_class],
172 'path' => [
'text', $a_path]
175 $DIC->database()->update(
'mail_tpl_ctx', [
176 'component' => [
'text', $a_component],
177 'class' => [
'text', $a_class],
178 'path' => [
'text', $a_path]
180 'id' => [
'text', $a_context->
getId()]
◆ getContextInstance()
static ilMailTemplateContextService::getContextInstance |
( |
string |
$a_component, |
|
|
string |
$a_id, |
|
|
string |
$a_class, |
|
|
?string |
$a_path, |
|
|
bool |
$isCreationContext = false |
|
) |
| |
|
staticprotected |
Definition at line 126 of file class.ilMailTemplateContextService.php.
References $context.
134 $a_path = $a_component .
'/classes/';
136 $class_file = $a_path .
'class.' . $a_class .
'.php';
138 if (class_exists($a_class) && file_exists($class_file)) {
139 if ($isCreationContext) {
141 $context = $reflClass->newInstanceWithoutConstructor();
Class ilMailTemplateContext.
◆ getTemplateContextById()
static ilMailTemplateContextService::getTemplateContextById |
( |
string |
$a_id | ) |
|
|
static |
◆ getTemplateContexts()
static ilMailTemplateContextService::getTemplateContexts |
( |
?array |
$a_id = null | ) |
|
|
static |
Returns an array of mail template contexts, the key of each entry matches its id.
- Parameters
-
- Returns
- ilMailTemplateContext[]
Definition at line 101 of file class.ilMailTemplateContextService.php.
References $context, $DIC, and $query.
Referenced by ilMailTemplateTableGUI\__construct(), ilMailTemplateGUI\getTemplateForm(), and ilMailTemplateGUI\showTemplates().
106 $query =
'SELECT * FROM mail_tpl_ctx';
108 if (is_array($a_id) && count($a_id)) {
109 $where[] = $DIC->database()->in(
'id', $a_id,
false,
'text');
112 $query .=
' WHERE ' . implode(
' AND ', $where);
115 $set = $DIC->database()->query(
$query);
116 while ($row = $DIC->database()->fetchAssoc($set)) {
117 $context = self::getContextInstance($row[
'component'], $row[
'id'], $row[
'class'], $row[
'path']);
Class ilMailTemplateContext.
◆ insertFromXML()
static ilMailTemplateContextService::insertFromXML |
( |
string |
$a_component, |
|
|
string |
$a_id, |
|
|
string |
$a_class, |
|
|
?string |
$a_path |
|
) |
| |
|
static |
The documentation for this class was generated from the following file: