[NFC] Remove some more of the old cvs blocks
[civicrm-core.git] / CRM / Core / Smarty / plugins / block.crmScope.php
index b37050b326d95867975dce14fff6eddc014c0e57..3e0e0280038625d4fbed68b8edbee3b8340e52df 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Example:
  *
- * @code
+ * ```
  * {tsScope x=1}
  *   Expect {$x}==1
  *   {tsScope x=2}
  *   {/tsScope}
  *   Expect {$x}==1
  * {/tsScope}
- * @endcode
+ * ```
  *
- * @param array $params must define 'name'
- * @param string $content Default content
- * @param object $smarty the Smarty object
+ * @param array $params
+ *   Must define 'name'.
+ * @param string $content
+ *   Default content.
+ * @param CRM_Core_Smarty $smarty
+ *   The Smarty object.
  *
  * @param $repeat
  *
  * @return string
  */
 function smarty_block_crmScope($params, $content, &$smarty, &$repeat) {
-  // A list of variables/values to save temporarily
-  static $backupFrames = array();
+  /** @var CRM_Core_Smarty $smarty */
 
   if ($repeat) {
     // open crmScope
-    $vars = $smarty->get_template_vars();
-    $backupFrame = array();
-    foreach ($params as $key => $value) {
-      $backupFrame[$key] = isset($vars[$key]) ? $vars[$key] : NULL;
-    }
-    $backupFrames[] = $backupFrame;
-    _smarty_block_crmScope_applyFrame($smarty, $params);
+    $smarty->pushScope($params);
   }
   else {
     // close crmScope
-    _smarty_block_crmScope_applyFrame($smarty, array_pop($backupFrames));
+    $smarty->popScope();
   }
 
   return $content;
 }
-
-/**
- * @param $smarty
- * @param $frame
- */
-function _smarty_block_crmScope_applyFrame(&$smarty, $frame) {
-  foreach ($frame as $key => $value) {
-    $smarty->assign($key, $value);
-  }
-}