/** * Get's the possible key used in the typemap for the type * * @param TypeInterface $type * @return string */ protected function getTypeMapKey(TypeInterface $type) { list($prefix, $shortname) = explode(':', $type->getRdfType()); $ns = $type->getVocabularies(); $ns = $ns[$prefix]; return $ns . $shortname; }
/** * {@inheritDoc} * * Create the object if a class is defined in the typeMap. This class * can not know how to set the parent, so if you ever create collection * entries, your extending class should handle the parent - it can still * call this method to create the basic object, just omit the parent * parameter and then set the parent on the returned value. For an example, * see DoctrinePhpcrOdmMapper. * * Just overwrite if you use a different concept. */ public function prepareObject(TypeInterface $type, $parent = null) { if ($parent !== null) { throw new \Exception('Parent is not null, please extend this method to configure the parent'); } list($prefix, $shortname) = explode(':', $type->getRdfType()); $ns = $type->getVocabularies(); $ns = $ns[$prefix]; $name = $ns.$shortname; if (isset($this->typeMap[$name])) { $class = $this->typeMap[$name]; return new $class; } throw new \Exception('No information on ' . $name); }