/** * Returns the {@link $obj} with the parsed NodeSchema attached * * @param ModelObject $obj The object to translate * * @return ModelObject {@link $obj} with the 'Schema' field set. */ public function preCacheTranslateObject(ModelObject $obj) { $plugin = $this->PluginService->getByID($obj->PluginID); if (empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled()) { return null; } if ($obj->getXMLSchema() != '') { // resolve schema $schemaXML = "<?xml version='1.0'?><schema>"; $schemaXML .= preg_replace('/\\<\\?xml([^\\>\\/]*)\\>/', '', $obj->getXMLSchema()); $schemaXML .= "</schema>"; try { $schema = $this->NodeSchemaParser->parse($schemaXML); } catch (Exception $e) { throw new SchemaException("Unable to parse schema for aspect [{$obj->Slug}]:\n " . $e->getMessage()); } $obj->setSchema($schema); } else { $obj->setSchema(new NodeSchema()); } return $obj; }