public function getManager(RdfMapperInterface $mapper) { $driver = new RdfDriverArray($this->_config['types']); $metadata = new RdfTypeFactory($mapper, $driver); $manager = new Manager($mapper, $metadata); if (!empty($this->_config['workflows'])) { foreach ($this->_config['workflows'] as $identifier => $classname) { $manager->getRestHandler()->registerWorkflow($identifier, new $classname()); } } if (!empty($this->_config['widget'])) { $manager->setWidget($this->_prepareWidget($this->_config['widget'], $manager)); } return $manager; }
public function render() { $js = '$(document).ready(function() {' . "\n"; $js .= '$("body").midgardCreate({' . "\n"; if (isset($this->_urls['rest'])) { $js .= 'url: function() {' . "\n"; $js .= 'return "' . $this->_urls['rest'] . '?subject=" + this.id' . "\n"; $js .= '},' . "\n"; } foreach ($this->_options as $name => $value) { if (is_string($value)) { $value = '"' . $value . '"'; } elseif ($value === true) { $value = 'true'; } elseif ($value === false) { $value = 'false'; } $js .= $name . ': ' . $value . ",\n"; } if (isset($this->_urls['workflows'])) { $js .= 'workflows: {' . "\n"; $js .= 'url: function(model) {' . "\n"; $js .= 'return "' . $this->_urls['workflows'] . '?subject=" + model.id' . "\n"; $js .= '}' . "\n"; $js .= '},' . "\n"; } $js = trim($js, "\n,"); $js .= '});' . "\n"; if (!empty($this->_editors)) { foreach ($this->_editors as $name => $config) { if (isset($this->_urls['upload'])) { $config = str_replace('__UPLOAD_URL__', $this->_urls['upload'], $config); } $js .= "\n\$('body').midgardCreate('configureEditor', '" . $name . "', 'halloWidget', {" . $config . "});\n"; } } foreach ($this->_manager->getLoadedTypes() as $identifier => $type) { foreach ($type->getChildDefinitions() as $key => $child) { if ($child instanceof Property) { $js .= "\n\$('body').midgardCreate('setEditorForProperty', '" . $child->getProperty() . "', '" . $child->getEditor() . "');\n"; } } } $js .= '});' . "\n"; return $js; }
public function test_getRestHandler() { $service = $this->manager->getRestHandler(); $this->assertInstanceOf('Midgard\\CreatePHP\\RestService', $service); }