public function create(array $attributes) { $name = $attributes[0]; $id = isset($attributes[1]) ? $attributes[1] : Null; $tag = new Tag($this, $name, $id); foreach ($this->listeners as $listener) { $tag->addListener($listener); } return $tag; }
public function removeChild(Tag $tag) { $found = null; foreach ($this->getChildren() as $id => $child) { if ((int) $child->id === (int) $tag->id) { $found = $id; break; } } if ($found === null) { throw new Exception('Tag ' . $tag->name . ' is not child of ' . $this->name); } unset($this->children[$found]); $this->removedChildren[] = $tag; $tag->setParent(Null); // $this->collection->unIndexParent($tag, $this); $this->changed = True; return $this; }
public function findByTag(Tag $tag) { return $this->getSelect('resource', $this->relationsTable, 'tag = ' . $tag->getId(), 'resource'); }