public function it_notifies_observers_when_characters_are_added(\SplObserver $observer, Character $character) { $observer->update($this)->shouldBeCalled(); $this->attach($observer); $this->givenCharacterHasCodepointWithValue($character, 1); $this->addMany(Character\Collection::fromArray([$character->getWrappedObject()])); }
function detach(SplObserver $observer) { echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; $idx = array_search($observer, $this->observers); if ($idx !== false) { unset($this->observers[$idx]); } }
function detach(SplObserver $observer) { echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; $this->observers->detach($observer); }
/** * Detaches an observer from the subject to no longer notify it of updates * * @param SplObserver $observer Instance of SplObserver to detach * * @return PHP_CompatInfo */ public function detach(SplObserver $observer) { $id = $observer->getHash(); if (isset($this->_observersId[$id])) { $this->_observers->detach($observer); unset($this->_observersId[$id]); } return $this; }
public function attach(\SplObserver $postit) { $this->_Postit[] = $postit; $postit->setState(true); $this->notify(); }
/** * Attaches an Observer * @param \SplObserver $observer */ public function attach(\SplObserver $observer) { if ($this->_observer === null) { $this->_observer = $observer; /* @var $observer \Jazz\IModel */ if ($observer->isLocked()) { $this->lock(); } } }