Merge pull request #14928 from lcdservices/dev-core-1158
[civicrm-core.git] / CRM / Core / Smarty / plugins / block.crmScope.php
CommitLineData
9915ae36
TO
1<?php
2
3/**
4 * Smarty block function to temporarily define variables.
5 *
6 * Example:
7 *
8 * @code
9 * {tsScope x=1}
10 * Expect {$x}==1
11 * {tsScope x=2}
12 * Expect {$x}==2
13 * {/tsScope}
14 * Expect {$x}==1
15 * {/tsScope}
16 * @endcode
17 *
6a0b768e
TO
18 * @param array $params
19 * Must define 'name'.
20 * @param string $content
21 * Default content.
16b10e64 22 * @param CRM_Core_Smarty $smarty
6a0b768e 23 * The Smarty object.
77b97be7
EM
24 *
25 * @param $repeat
9915ae36
TO
26 *
27 * @return string
28 */
29function smarty_block_crmScope($params, $content, &$smarty, &$repeat) {
17f267d6 30 /** @var CRM_Core_Smarty $smarty */
9915ae36
TO
31
32 if ($repeat) {
33 // open crmScope
17f267d6 34 $smarty->pushScope($params);
9915ae36
TO
35 }
36 else {
37 // close crmScope
17f267d6 38 $smarty->popScope();
9915ae36
TO
39 }
40
41 return $content;
42}