Exemplo n.º 1
0
 private function processChildrenTypes(Description $description, Metadata $metadata, Request $request, $payload)
 {
     $childClasses = $description->get(Descriptor::CHILDREN_TYPES);
     $childLinks = [];
     foreach ($childClasses as $childClass) {
         try {
             $metadata = $this->registry->getByClass($childClass);
         } catch (\InvalidArgumentException $e) {
             continue;
         }
         $configuration = $this->requestConfigurationFactory->create($metadata, $request);
         $url = $this->urlGenerator->generate($configuration->getRouteName('create'));
         $childLinks[$metadata->getAlias()] = $url . '?parent=' . $payload->getId();
     }
     $description->set(Descriptor::LINKS_CREATE_CHILD_HTML, $childLinks);
 }
Exemplo n.º 2
0
 /**
  * It should throw an exception when requesting an unsupported descriptor.
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Supported descriptors: "foo", "bar"
  */
 public function testGetUnsupported()
 {
     $this->description->set('foo', 'bar');
     $this->description->set('bar', 'foo');
     $this->description->get('not there');
 }