thrownewMappingException("You must define a locale mapping for translatable document '".$this->name."'");

}

}

// we allow mixed referrers on non-referenceable documents. maybe the mix:referenceable is just not mapped

if (count($this->referrersMappings)) {

if (!$this->referenceable) {

thrownewMappingException('You can not have referrers mapped on document "'.$this->name.'" as the document is not referenceable');

}

foreach ($this->referrersMappingsas$referrerName) {

$mapping=$this->mappings[$referrerName];

// only a santiy check with reflection. otherwise we could run into endless loops

if (!ClassLoader::classExists($mapping['referringDocument'])) {

thrownewMappingException(sprintf('Invalid referrer mapping on document "%s" for field "%s": The referringDocument class "%s" does not exist', $this->name, $mapping['fieldName'], $mapping['referringDocument']));

}

$reflection=newReflectionClass($mapping['referringDocument']);

if (!$reflection->hasProperty($mapping['referencedBy'])) {

thrownewMappingException(sprintf('Invalid referrer mapping on document "%s" for field "%s": The referringDocument "%s" has no property "%s"', $this->name, $mapping['fieldName'], $mapping['referringDocument'], $mapping['referencedBy']));

}

}

}

$this->validateIdentifier();

}

/**

* Determine the id strategy for this document. Only call this if no explicit

* strategy was assigned.

*

* @throws MappingException if no strategy is applicable with the mapped fields.

*/

privatefunctiondetermineIdStrategy()

{

if ($this->parentMapping&&$this->nodename) {

$this->setIdGenerator(self::GENERATOR_TYPE_PARENT);

return;

}

if ($this->parentMapping) {

$this->setIdGenerator(self::GENERATOR_TYPE_AUTO);

return;

}

if ($this->getIdentifier()) {

$this->setIdGenerator(self::GENERATOR_TYPE_ASSIGNED);

return;

}

thrownewMappingException(sprintf('No id generator could be determined in "%s". Either map a parent and a nodename field and add values to them, or map the id field and configure a mapping strategy', $this->name));