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


PHP CKFinder_Connector_Core_Hooks::_printCallback方法代码示例

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


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

示例1: run

 /**
  * Run user defined hooks
  *
  * @param string $event
  * @param object $errorHandler
  * @param array $args
  * @return boolean (true to continue processing, false otherwise)
  */
 public static function run($event, $args = array())
 {
     $config = $GLOBALS['config'];
     if (!isset($config['Hooks'])) {
         return true;
     }
     $hooks =& $config['Hooks'];
     if (!is_array($hooks) || !array_key_exists($event, $hooks) || !is_array($hooks[$event])) {
         return true;
     }
     $errorHandler = $GLOBALS['connector']->getErrorHandler();
     foreach ($hooks[$event] as $i => $hook) {
         $object = NULL;
         $method = NULL;
         $function = NULL;
         $data = NULL;
         $passData = false;
         /* $hook can be: a function, an object, an array of $functiontion and $data,
          * an array of just a function, an array of object and method, or an
          * array of object, method, and data.
          */
         //function
         if (is_string($hook)) {
             $function = $hook;
         } else {
             if (is_object($hook)) {
                 $object = $hooks[$event][$i];
                 $method = "on" . $event;
             } else {
                 if (is_array($hook)) {
                     $count = count($hook);
                     if ($count) {
                         //...object
                         if (is_object($hook[0])) {
                             $object = $hooks[$event][$i][0];
                             if ($count < 2) {
                                 $method = "on" . $event;
                             } else {
                                 //...object and method
                                 $method = $hook[1];
                                 if (count($hook) > 2) {
                                     //...object, method and data
                                     $passData = true;
                                     $data = $hook[2];
                                 }
                             }
                         } else {
                             if (is_string($hook[0])) {
                                 $function = $hook[0];
                                 if ($count > 1) {
                                     //...function with data
                                     $passData = true;
                                     $data = $hook[1];
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /* If defined, add data to the arguments array */
         if ($passData) {
             $args = array_merge(array($data), $args);
         }
         if (isset($object)) {
             $callback = array($object, $method);
         } else {
             if (false !== ($pos = strpos($function, '::'))) {
                 $callback = array(substr($function, 0, $pos), substr($function, $pos + 2));
             } else {
                 $callback = $function;
             }
         }
         if (is_callable($callback)) {
             $ret = call_user_func_array($callback, $args);
         } else {
             $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback);
             $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, "CKFinder failed to call a hook: " . $functionName);
             return false;
         }
         //String return is a custom error
         if (is_string($ret)) {
             $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, $ret);
             return false;
         } else {
             if (is_int($ret)) {
                 $errorHandler->throwError($ret);
                 return false;
             } else {
                 if ($ret === null) {
                     $functionName = CKFinder_Connector_Core_Hooks::_printCallback($callback);
                     $errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR, "CKFinder extension returned an invalid value (null)." . "Hook " . $functionName . " should return a value.");
//.........这里部分代码省略.........
开发者ID:jambik,项目名称:elenaburgon,代码行数:101,代码来源:Hooks.php


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