Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function getAllNames()
 {
     $map = array();
     foreach ($this->definitions as $name => $definition) {
         $type = $name;
         if (isset($definition['typeof'])) {
             $type = $definition['typeof'];
             if (isset($definition['vocabularies'])) {
                 $type = NamespaceHelper::expandNamespace($definition['typeof'], $definition['vocabularies']);
             }
         }
         $map[$type] = $name;
     }
     return $map;
 }
Exemplo n.º 2
0
 /**
  * Handle post request
  *
  * Find a reverse mapping to the parent, into received data and type
  * reverse options. The mapping is used to create the entity to store.
  *
  * @param array $received_data
  * @param TypeInterface $type type of the node to create
  * @return array|null
  */
 private function _handleCreate($received_data, TypeInterface $type)
 {
     $parent = null;
     foreach ($type->getRevOptions() as $option) {
         $rdf = NamespaceHelper::expandNamespace($option, $type->getVocabularies());
         $about = $received_data[$this->jsonldEncode($rdf)];
         if (!empty($about)) {
             $parent = $this->_mapper->getBySubject($this->jsonldDecode(current($about)));
             break;
         }
     }
     $object = $this->_mapper->prepareObject($type, $parent);
     $entity = $type->createWithObject($object);
     return $this->_storeData($received_data, $entity);
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function getAllNames()
 {
     $classes = array();
     foreach ($this->directories as $dir) {
         foreach (glob($dir . DIRECTORY_SEPARATOR . '*.xml') as $file) {
             $xml = simplexml_load_file($file);
             $namespaces = $xml->getDocNamespaces();
             $type = NamespaceHelper::expandNamespace($xml['typeof'], $namespaces);
             $classes[$type] = $this->buildClassName(basename($file));
         }
     }
     return $classes;
 }