Beispiel #1
0
 /**
  * @param $class
  *
  * @return RepositoryInterface
  */
 private function createRepository($class)
 {
     $metadata = $this->metadataRegistry->getMetadataForClass($class);
     $repositoryClass = $metadata->getRepositoryClass();
     $repository = $this->instantiateRepository($repositoryClass, $class);
     if (!$repository instanceof RepositoryInterface) {
         throw new InvalidArgumentException(sprintf('Repositories must implement "Tystr\\RestOrm\\Repository\\RepositoryInterface'));
     }
     return $repository;
 }
 /**
  * @param Hal    $hal
  * @param string $class
  *
  * @return array
  */
 protected function getDataFromHal(Hal $hal, $class)
 {
     $class = preg_match('/array<([^>]*)>/', $class, $matches) ? $matches[1] : $class;
     $metadata = $this->metadataRegistry->getMetadataForClass($class);
     $data = $this->flattenHal($hal);
     reset($data);
     if (count($data) === 1 && key($data) === $metadata->getEmbeddedRel()) {
         $data = $data[key($data)];
     }
     return $data;
 }
Beispiel #3
0
 /**
  * @param object $object
  * @param array  $parameters
  * @param array  $requirements
  *
  * @return Request
  */
 public function createDeleteRequest($object, array $parameters = [], array $requirements = [])
 {
     $metadata = $this->metadataRegistry->getMetadataForClass(get_class($object));
     return new Request('DELETE', $this->urlGenerator->getRemoveUrl($metadata->getResource(), $metadata->getIdentifierValue($object), $parameters, $requirements), ['Content-Type' => $this->getContentTypeHeader()]);
 }