name = $name; $this->type = $type; $this->isDocumentOrderable = $isDocumentOrderable; $this->writemetaOriginalDocument = $writemetaOriginalDocument; } /** * @return string */ public function getName() { return $this->name; } /** * @return Type */ public function getType() { return $this->type; } public function allowDocumentOrdering() { $this->isDocumentOrderable = true; } public function disallowDocumentOrdering() { $this->isDocumentOrderable = false; } /** * @return bool */ public function isDocumentOrderable() { return $this->isDocumentOrderable; } /** * @return bool */ public function toWritemetaOriginalDocument() { return $this->writemetaOriginalDocument; } public function addSubdef(\databox_subdef $subdef) { $this->subdefs[$subdef->get_name()] = $subdef; } /** * @param string|\databox_subdef $subdef * @return bool */ public function hasSubdef($subdef) { $subdefName = $subdef instanceof \databox_subdef ? $subdef->get_name() : $subdef; return isset($this->subdefs[$subdefName]); } /** * @param string $subdefName * @return \databox_subdef */ public function getSubdef($subdefName) { if (!isset($this->subdefs[$subdefName])) { throw new \RuntimeException('Requested subdef was not found'); } return $this->subdefs[$subdefName]; } /** * @param string|\databox_subdef $subdef */ public function removeSubdef($subdef) { $subdefName = $subdef instanceof \databox_subdef ? $subdef->get_name() : $subdef; unset($this->subdefs[$subdefName]); } public function getIterator() { return new \ArrayIterator($this->subdefs); } public function count() { return count($this->subdefs); } }