ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilUpdateNewAccountMailTemplatesForMustache Class Reference
+ Inheritance diagram for ilUpdateNewAccountMailTemplatesForMustache:
+ Collaboration diagram for ilUpdateNewAccountMailTemplatesForMustache:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Data Fields

const NUMBER_OF_STEPS = 10000
 
- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Protected Member Functions

 getNextLangToBeUpdated ()
 
 getWhere ()
 
 replace (string $lang, string $regex_search, string $replacement)
 
 replaceRemainingBrackets (string $lang)
 
 replaceInText (?string $text, string $regex_search, string $replacement)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilUpdateNewAccountMailTemplatesForMustache::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 35 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

35  : int
36  {
37  return self::NUMBER_OF_STEPS;
38  }

◆ getLabel()

ilUpdateNewAccountMailTemplatesForMustache::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 30 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

30  : string
31  {
32  return 'ilUpdateNewAccountMailTemplatesForMustache';
33  }

◆ getNextLangToBeUpdated()

ilUpdateNewAccountMailTemplatesForMustache::getNextLangToBeUpdated ( )
protected

Definition at line 75 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References $q, $res, and getWhere().

Referenced by step().

75  : ?string
76  {
77  $this->db->setLimit(1);
78  $q = 'SELECT lang FROM mail_template ' . PHP_EOL . $this->getWhere();
79  $res = $this->db->query($q);
80 
81  if ($this->db->numRows($res) === 0) {
82  return null;
83  }
84 
85  $row = $this->db->fetchAssoc($res);
86 
87  return $row['lang'];
88  }
$res
Definition: ltiservices.php:69
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreconditions()

ilUpdateNewAccountMailTemplatesForMustache::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 40 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

40  : array
41  {
42  return [
43  new \ilDatabaseUpdatedObjective()
44  ];
45  }

◆ getRemainingAmountOfSteps()

ilUpdateNewAccountMailTemplatesForMustache::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 66 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References $q, $res, and getWhere().

66  : int
67  {
68  $q = 'SELECT COUNT(*) AS open FROM mail_template ' . PHP_EOL . $this->getWhere();
69  $res = $this->db->query($q);
70  $row = $this->db->fetchAssoc($res);
71 
72  return (int) $row['open'];
73  }
$res
Definition: ltiservices.php:69
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ getWhere()

ilUpdateNewAccountMailTemplatesForMustache::getWhere ( )
protected

Definition at line 90 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References ilDBConstants\T_TEXT.

Referenced by getNextLangToBeUpdated(), and getRemainingAmountOfSteps().

90  : string
91  {
92  return ' WHERE (' . PHP_EOL
93  . $this->db->like('body', ilDBConstants::T_TEXT, '%[%') . ' OR ' . PHP_EOL
94  . $this->db->like('body', ilDBConstants::T_TEXT, '%]%') . ' OR ' . PHP_EOL
95  . $this->db->like('subject', ilDBConstants::T_TEXT, '%[%') . ' OR ' . PHP_EOL
96  . $this->db->like('subject', ilDBConstants::T_TEXT, '%]%') . PHP_EOL
97  . ') AND type = ' . $this->db->quote('nacc', ilDBConstants::T_TEXT);
98  }
+ Here is the caller graph for this function:

◆ prepare()

ilUpdateNewAccountMailTemplatesForMustache::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 47 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References ILIAS\Setup\Environment\getResource().

47  : void
48  {
49  $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
50  }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ Here is the call graph for this function:

◆ replace()

ilUpdateNewAccountMailTemplatesForMustache::replace ( string  $lang,
string  $regex_search,
string  $replacement 
)
protected

Definition at line 100 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References $res, replaceInText(), and ilDBConstants\T_TEXT.

Referenced by step().

100  : void
101  {
102  $res = $this->db->queryF(
103  'SELECT subject, body FROM mail_template WHERE lang = %s AND type = %s',
105  [$lang, 'nacc']
106  );
107  if ($this->db->numRows($res) === 1) {
108  $row = $this->db->fetchAssoc($res);
109 
110  $subject = $this->replaceInText(
111  $row['subject'],
112  $regex_search,
113  $replacement
114  );
115  $body = $this->replaceInText(
116  $row['body'],
117  $regex_search,
118  $replacement
119  );
120 
121  $this->db->manipulateF(
122  'UPDATE mail_template SET subject = %s, body = %s WHERE lang = %s AND type = %s',
124  [$subject, $body, $lang, 'nacc']
125  );
126  }
127  }
$res
Definition: ltiservices.php:69
replaceInText(?string $text, string $regex_search, string $replacement)
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceInText()

ilUpdateNewAccountMailTemplatesForMustache::replaceInText ( ?string  $text,
string  $regex_search,
string  $replacement 
)
protected

Definition at line 158 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

Referenced by replace(), and replaceRemainingBrackets().

162  : ?string {
163  if ($text === null) {
164  return null;
165  }
166 
167  return preg_replace(
168  $regex_search,
169  $replacement,
170  $text
171  );
172  }
+ Here is the caller graph for this function:

◆ replaceRemainingBrackets()

ilUpdateNewAccountMailTemplatesForMustache::replaceRemainingBrackets ( string  $lang)
protected

Definition at line 129 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References $res, replaceInText(), and ilDBConstants\T_TEXT.

Referenced by step().

129  : void
130  {
131  $res = $this->db->queryF(
132  'SELECT subject, body FROM mail_template WHERE lang = %s AND type = %s',
134  [$lang, 'nacc']
135  );
136  if ($this->db->numRows($res) === 1) {
137  $row = $this->db->fetchAssoc($res);
138 
139  $subject = $this->replaceInText(
140  $row['subject'],
141  '/\[([A-Z_\/]+?)\]/',
142  '{{$1}}'
143  );
144  $body = $this->replaceInText(
145  $row['body'],
146  '/\[([A-Z_\/]+?)\]/',
147  '{{$1}}'
148  );
149 
150  $this->db->manipulateF(
151  'UPDATE mail_template SET subject = %s, body = %s WHERE lang = %s AND type = %s',
153  [$subject, $body, $lang, 'nacc']
154  );
155  }
156  }
$res
Definition: ltiservices.php:69
replaceInText(?string $text, string $regex_search, string $replacement)
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ step()

ilUpdateNewAccountMailTemplatesForMustache::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 52 of file class.ilUpdateNewAccountMailTemplatesForMustache.php.

References $lang, getNextLangToBeUpdated(), replace(), and replaceRemainingBrackets().

52  : void
53  {
54  $lang = $this->getNextLangToBeUpdated();
55  if ($lang === null) {
56  return;
57  }
58 
59  $this->replace($lang, '/\[IF_PASSWORD\]/', '{{#IF_PASSWORD}}');
60  $this->replace($lang, '/\[IF_NO_PASSWORD\]/', '{{#IF_NO_PASSWORD}}');
61  $this->replace($lang, '/\[IF_TARGET\]/', '{{#IF_TARGET}}');
62  $this->replace($lang, '/\[IF_TIMELIMIT\]/', '{{#IF_TIMELIMIT}}');
64  }
$lang
Definition: xapiexit.php:26
replace(string $lang, string $regex_search, string $replacement)
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilUpdateNewAccountMailTemplatesForMustache::$db
protected

◆ NUMBER_OF_STEPS

const ilUpdateNewAccountMailTemplatesForMustache::NUMBER_OF_STEPS = 10000

The documentation for this class was generated from the following file: