当前位置: 首页>>代码示例>>PHP>>正文


PHP Q_Response::slotName方法代码示例

本文整理汇总了PHP中Q_Response::slotName方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Response::slotName方法的具体用法?PHP Q_Response::slotName怎么用?PHP Q_Response::slotName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q_Response的用法示例。


在下文中一共展示了Q_Response::slotName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fillSlot

 /**
  * Gets the current content of a slot, if any.
  * If slot content is null, then raises an event
  * to try to fill the slot. If it is filled,
  * returns the content. Otherwise, returns null.
  * @method fillSlot
  * @static
  * @param {string|array} $slotName The name of the slot.
  * @param {boolean} [$default_slotName=null] If the slot named in $slotName returns null,
  *  the handler corresponding to the default slot will be called,
  *  passing it the requested slot's name in the 'slotName' parameter,
  *  and its value will be returned instead.
  *  Note: this does not fill the slot named $default_slotName!
  *  That is to say, the computed value is not saved, so that
  *  the slot's handler is called again if it is ever consulted again.
  * @param {string} [$prefix=null] Sets a prefix for the HTML ids of all the elements in the slot.
  * @return {string|null}
  */
 static function fillSlot($slotName, $default_slotName = null, $prefix = null)
 {
     if (isset(self::$slots[$slotName])) {
         return self::$slots[$slotName];
     }
     $prev_slotName = self::$slotName;
     self::$slotName = $slotName;
     if (isset($prefix)) {
         Q_Html::pushIdPrefix($prefix);
     }
     try {
         if (isset($default_slotName)) {
             if (!Q::canHandle("Q/response/{$slotName}")) {
                 /**
                  * @event Q/response/$default_slotName
                  * @param {string} slotName
                  * @return {string}
                  */
                 $result = Q::event("Q/response/{$default_slotName}", compact('slotName'));
                 if (isset(self::$slots[$slotName])) {
                     // The slot was already filled, while we were rendering it
                     // so discard the $result and return the slot's contents
                     return self::$slots[$slotName];
                 }
                 return self::$slots[$slotName] = $result;
             }
         }
         /**
          * @event Q/response/$slotName
          * @return {string}
          */
         $result = Q::event("Q/response/{$slotName}");
     } catch (Exception $e) {
         self::$slotName = $prev_slotName;
         if (isset($prefix)) {
             Q_Html::popIdPrefix();
         }
         throw $e;
     }
     self::$slotName = $prev_slotName;
     if (isset($prefix)) {
         Q_Html::popIdPrefix();
     }
     if (isset(self::$slots[$slotName])) {
         // The slot was already filled, while we were rendering it
         // so discard the $result and return the slot's contents
         return self::$slots[$slotName];
     }
     if (isset($result)) {
         self::setSlot($slotName, $result);
         return $result;
     }
     // Otherwise, render default slot
     if (!isset($default_slotName)) {
         return null;
     }
     /**
      * @event Q/response/$default_slotName
      * @param {string} slotName
      * @return {string}
      */
     return Q::event("Q/response/{$default_slotName}", compact('slotName'));
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:81,代码来源:Response.php


注:本文中的Q_Response::slotName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。