/**
  * @Route("/{reference}", methods={"PUT"}, name="manifest_put")
  *
  * @ParamConverter("manifest", options={"repository_method": "findOneByReferenceOrCreate", "map_method_signature": true})
  *
  * @Security("is_granted('REPO_WRITE', repository)")
  *
  * @link http://docs.docker.com/registry/spec/api/#put-manifest
  */
 public function uploadAction(Request $request, Repository $repository, Manifest $manifest, $reference)
 {
     $manifest->setContent($request->getContent());
     if ($reference !== $manifest->getTag() && $reference !== $manifest->getDigest()) {
         throw new BadRequestHttpException('Provided reference does not match with tag or digest.');
     }
     // TODO: validate layers & signatures
     $this->get('doctrine')->getRepository('AppBundle:Manifest')->save($manifest);
     // Dispatch event
     $event = new ManifestEvent($manifest);
     $this->get('event_dispatcher')->dispatch('delayed', new DelayedEvent('kernel.terminate', 'manifest.push', $event));
     return new Response('', Response::HTTP_CREATED, ['Location' => $this->generateUrl('manifest_get', ['name' => $manifest->getRepository()->getName(), 'reference' => $manifest->getDigest()], UrlGeneratorInterface::ABSOLUTE_URL), 'Docker-Content-Digest' => $manifest->getDigest()]);
 }
 /**
  * @Given I have manifests:
  */
 public function iHaveManifests(TableNode $table)
 {
     $manifestsPath = __DIR__ . '/../fixtures/manifests/';
     $em = $this->getEntityManager();
     foreach ($table->getRows() as $row) {
         $content = file_get_contents($manifestsPath . $row[0]);
         $repository = $em->getRepository('AppBundle:Repository')->findOneByName(json_decode($content, true)['name']);
         $manifest = new Manifest($repository);
         $manifest->setContent($content);
         $em->persist($manifest);
     }
     $em->flush();
 }