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


PHP ObjectCollection类代码示例

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


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

示例1: changeEditor

 /**
  * Changes the editor on the fly
  *
  * @param string $editor String name of editor, excluding the word 'Helper'
  * @return void
  * @author Jose Diaz-Gonzalez
  **/
 public function changeEditor($editor)
 {
     $this->helper = ucfirst($editor);
     $prefix = '';
     if ($editor !== 'Form') {
         $prefix = 'Wysiwyg.';
     }
     if (!$this->importedHelpers[$this->helper]) {
         $this->importedHelpers[$this->helper] = true;
         $this->helpers[] = $prefix . $this->helper;
         $this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers);
     }
 }
开发者ID:rchavik,项目名称:cakephp-wysiwyg-helper,代码行数:20,代码来源:WysiwygHelper.php

示例2: testAdd

  function testAdd()
  {
    $obj1 = new Object();
    $obj1->set('id', 1);

    $obj2 = new Object();
    $obj2->set('id', 2);

    $arr = array($obj1);
    $col = new ObjectCollection($arr);

    $col->add($obj2);

    $col->rewind();

    $this->assertEqual($col->current(), $obj1);

    $col->next();
    $this->assertEqual($col->current(), $obj2);

    $col->next();
    $this->assertFalse($col->valid());
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:23,代码来源:ObjectCollectionTest.class.php

示例3: __construct

 /**
  * Default Constructor
  *
  * @param View $View The View this helper is being attached to.
  * @param array $settings Configuration settings for the helper.
  */
 public function __construct(View $View, $settings = array())
 {
     $this->_View = $View;
     $this->request = $View->request;
     if (!empty($this->helpers)) {
         $this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers);
     }
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:14,代码来源:Helper.php

示例4: testnormalizeObjectArray

 /**
  * test normalizeObjectArray
  *
  * @return void
  */
 public function testnormalizeObjectArray()
 {
     $components = array('Html', 'Foo.Bar' => array('one', 'two'), 'Something', 'Banana.Apple' => array('foo' => 'bar'));
     $result = ObjectCollection::normalizeObjectArray($components);
     $expected = array('Html' => array('class' => 'Html', 'settings' => array()), 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), 'Something' => array('class' => 'Something', 'settings' => array()), 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')));
     $this->assertEquals($expected, $result);
     // This is the result after Controller::_mergeVars
     $components = array('Html' => null, 'Foo.Bar' => array('one', 'two'), 'Something' => null, 'Banana.Apple' => array('foo' => 'bar'));
     $result = ObjectCollection::normalizeObjectArray($components);
     $this->assertEquals($expected, $result);
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:16,代码来源:ObjectCollectionTest.php

示例5: array

<?php

namespace DesignPatterns\Strategy;

/**
 * strategy pattern
 *
 * Terminology:
 * - Context
 * - Strategy
 * - Concrete Strategy
 *
 * Purpose:
 * to separate strategies and to enable fast switching between them.
 * also this pattern is a good alternative to inheritance (instead of having an abstract class that is extended)
 *
 * Examples:
 * - sorting a list of objects, one strategy by date, the other by id
 * - simplify unit testing: e.g. switching between file and in-memory storage
 *
 */
$elements = array(array('id' => 2, 'date' => '2011-01-01'), array('id' => 1, 'date' => '2011-02-01'));
$collection = new ObjectCollection($elements);
$collection->setComparator(new IdComparator());
$collection->sort();
$collection->setComparator(new DateComparator());
$collection->sort();
开发者ID:Kravalg,项目名称:DesignPatternsPHP,代码行数:27,代码来源:index.php

示例6: error_reporting

<?php

require 'Strategy/ObjectCollection.php';
require 'Strategy/ComparerInterface.php';
require 'Strategy/TitleComparer.php';
require 'Strategy/DateComparer.php';
require 'Strategy/AuthorComparer.php';
error_reporting(E_ALL);
ini_set("display_errors", 1);
$elements = array(array('title' => 'Bushcraft 101: A Field Guide to the Art of Wilderness Survival', 'pub-date' => '2014-09-01', 'author' => 'Dave Canterbury'), array('title' => 'Complexity and the Arrow of Time', 'pub-date' => '2013-09-23', 'author' => 'Charles H. Lineweaver'), array('title' => 'Parable of the Sower', 'pub-date' => '2000-01-01', 'author' => 'Octavia E. Butler'), array('title' => 'JavaScript: The Good Parts', 'pub-date' => '2008-05-01', 'author' => 'Douglas Crockford'));
$type = !empty($_GET['type']) ? htmlspecialchars($_GET['type']) : 'title';
$collection = new ObjectCollection($elements);
switch ($type) {
    case 'date':
        $collection->setComparer(new DateComparer());
        break;
    case 'author':
        $collection->setComparer(new AuthorComparer());
        break;
    case 'title':
    default:
        $collection->setComparer(new TitleComparer());
}
$collection->sort();
$collection->display();
开发者ID:swos-,项目名称:patterns,代码行数:25,代码来源:index.php

示例7: changeEditor

 /**
  * Changes the editor on the fly
  *
  * @param string $editor String name of editor, excluding the word 'Helper'
  * @param array $helperOptions Each type of wysiwyg helper takes different options.
  * @return void
  * @throws MissingHelperException
  **/
 public function changeEditor($editor, $helperOptions = array())
 {
     $this->helper = ucfirst($editor);
     if (!empty($helperOptions)) {
         $this->updateSettings($helperOptions);
     }
     if (!isset($this->importedHelpers[$this->helper])) {
         throw new MissingHelperException(sprintf("Missing Wysiwyg.%s Helper", $this->helper));
     }
     if (!$this->importedHelpers[$this->helper]) {
         $class = 'Wysiwyg.' . $this->helper;
         $helpers = ObjectCollection::normalizeObjectArray(array($class));
         foreach ($helpers as $properties) {
             list($plugin, $class) = pluginSplit($properties['class']);
             $this->{$class} = $this->_View->Helpers->load($properties['class'], $properties['settings']);
         }
         $this->importedHelpers[$this->helper] = true;
     }
 }
开发者ID:anujjaha,项目名称:angels,代码行数:27,代码来源:WysiwygHelper.php

示例8: unload

 /**
  * Detaches a behavior from a model
  *
  * @param string $name CamelCased name of the behavior to unload
  * @return void
  */
 public function unload($name)
 {
     list(, $name) = pluginSplit($name);
     if (isset($this->_loaded[$name])) {
         $this->_loaded[$name]->cleanup(ClassRegistry::getObject($this->modelName));
         parent::unload($name);
     }
     foreach ($this->_methods as $m => $callback) {
         if (is_array($callback) && $callback[0] === $name) {
             unset($this->_methods[$m]);
         }
     }
 }
开发者ID:saihe,项目名称:reservation,代码行数:19,代码来源:BehaviorCollection.php

示例9: 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

示例10: add

 function add(&$obj)
 {
   $this->_ensureCollection();
   parent :: add($obj);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:5,代码来源:ProxyObjectCollection.class.php

示例11: __construct

 public function __construct(NodeSchema $node_schema)
 {
     parent::__construct($node_schema);
 }
开发者ID:karwana,项目名称:penelope,代码行数:4,代码来源:NodeCollection.php


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