Example #1
0
 function addField($name, $flags = 0)
 {
     $db = Application::getStructureDb();
     // check if field is already set by querying on it.
     // If we want to match multiple fields in the array we would
     // have to use the $elemMatch operator.
     //        $db->content_type->findOne(array(
     //        	'name' => $this->_data['name'],
     //        	'fields' => array('$elemMatch' => array('name' => $name)))
     if ($db->content_type->findOne(array('name' => $this->_data['name'], 'fields.name' => $name))) {
         throw new Content_Type_Exception('Duplicate content type field "' . $name . '"', Content_Type_Exception::CODE_DUP_FIELD);
     }
     $fields = isset($this->_data['fields']) ? $this->_data['fields'] : array();
     $fields[] = array('name' => $name, 'flags' => $flags);
     $this->_data['fields'] = $fields;
     $this->_save();
     return $this;
 }
Example #2
0
 protected static function _getDb()
 {
     return Application::getStructureDb();
 }