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


PHP ObjectCollection::trigger方法代码示例

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


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

示例1: trigger

 /**
  * Trigger a callback method on every object in the collection.
  * Used to trigger methods on objects in the collection. Will fire the methods in the
  * order they were attached.
  *
  * ### Options
  *
  * - `breakOn` Set to the value or values you want the callback propagation to stop on.
  *    Can either be a scalar value, or an array of values to break on. Defaults to `false`.
  *
  * - `break` Set to true to enabled breaking. When a trigger is broken, the last returned value
  *    will be returned. If used in combination with `collectReturn` the collected results will be returned.
  *    Defaults to `false`.
  *
  * - `collectReturn` Set to true to collect the return of each object into an array.
  *    This array of return values will be returned from the trigger() call. Defaults to `false`.
  *
  * - `modParams` Allows each object the callback gets called on to modify the parameters to the next object.
  *    Setting modParams to an integer value will allow you to modify the parameter with that index.
  *    Any non-null value will modify the parameter index indicated.
  *    Defaults to false.
  *
  * @param string|CakeEvent $callback Method to fire on all the objects. Its assumed all the objects implement
  *   the method you are calling. If an instance of CakeEvent is provided, then then Event name will parsed to
  *   get the callback name. This is done by getting the last word after any dot in the event name
  *   (eg. `Model.afterSave` event will trigger the `afterSave` callback)
  * @param array $params Array of parameters for the triggered callback.
  * @param array $options Array of options.
  * @return mixed Either the last result or all results if collectReturn is on.
  * @throws CakeException when modParams is used with an index that does not exist.
  */
 public function trigger($callback, $params = array(), $options = array())
 {
     if ($callback instanceof CakeEvent) {
         $callback->omitSubject = true;
     }
     return parent::trigger($callback, $params, $options);
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:38,代码来源:HelperCollection.php


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