public function addMixin($mixinName)
{
// Check if mixinName exists as a mixin type
$typemgr = $this->session->getWorkspace()->getNodeTypeManager();
$nodeType = $typemgr->getNodeType($mixinName);
if (!$nodeType->isMixin()) {
throw new ConstraintViolationException("Trying to add a mixin '{$mixinName}' that is a primary type");
}
$this->checkState();
// TODO handle LockException & VersionException cases
if ($this->hasProperty('jcr:mixinTypes')) {
if (!in_array($mixinName, $this->properties['jcr:mixinTypes']->getValue())) {
$this->properties['jcr:mixinTypes']->addValue($mixinName);
$this->setModified();
}
} else {
$this->setProperty('jcr:mixinTypes', array($mixinName), PropertyType::NAME);
$this->setModified();
}
}