コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function unregister($service)
 {
     if (!$this->has($service)) {
         throw new NonExistingServiceException($this->context, gettype($service), array_keys($this->services->toArray()));
     }
     $this->services->remove($service);
 }
コード例 #2
0
    /**
     * Make a deep clone of a fieldset
     *
     * @return void
     */
    public function __clone()
    {
        $items = $this->iterator->toArray(PriorityQueue::EXTR_BOTH);

        $this->byName    = array();
        $this->elements  = array();
        $this->fieldsets = array();
        $this->iterator  = new PriorityQueue();

        foreach ($items as $item) {
            $elementOrFieldset = clone $item['data'];
            $name = $elementOrFieldset->getName();

            $this->iterator->insert($elementOrFieldset, $item['priority']);
            $this->byName[$name] = $elementOrFieldset;

            if ($elementOrFieldset instanceof FieldsetInterface) {
                $this->fieldsets[$name] = $elementOrFieldset;
            } elseif ($elementOrFieldset instanceof ElementInterface) {
                $this->elements[$name] = $elementOrFieldset;
            }
        }

        // Also make a deep copy of the object in case it's used within a collection
        if (is_object($this->object)) {
            $this->object = clone $this->object;
        }
    }
コード例 #3
0
 public function testCanCastToArrayOfDataPriorityPairs()
 {
     $expected = array(
         array('data' => 'foo', 'priority' => 3),
         array('data' => 'bar', 'priority' => 4),
         array('data' => 'baz', 'priority' => 2),
         array('data' => 'bat', 'priority' => 1),
     );
     $test     = $this->queue->toArray(PriorityQueue::EXTR_BOTH);
     $this->assertSame($expected, $test, var_export($test, 1));
 }
コード例 #4
0
 /**
  * Get all the validators
  *
  * @return array
  */
 public function getValidators()
 {
     return $this->validators->toArray(PriorityQueue::EXTR_DATA);
 }