Ejemplo n.º 1
0
 /**
  * @param $name
  * @return mixed|null
  */
 public function getTemplate($name)
 {
     $template = $this->parameters->get('template', $this->getDefaultTemplate($name));
     if (null === $template) {
         throw new \RuntimeException(sprintf('Could not resolve template for resource "%s".', $this->metadata->getAlias()));
     }
     return $template;
 }
Ejemplo n.º 2
0
 function it_returns_specific_metadata_by_model_class(MetadataInterface $metadata1, MetadataInterface $metadata2)
 {
     $metadata1->getAlias()->willReturn('app.product');
     $metadata1->getClass('model')->willReturn('App\\Model\\Product');
     $metadata2->getAlias()->willReturn('app.order');
     $metadata2->getClass('model')->willReturn('App\\Model\\Order');
     $this->add($metadata1);
     $this->add($metadata2);
     $this->getByClass('App\\Model\\Order')->shouldReturn($metadata2);
 }
Ejemplo n.º 3
0
 /**
  * @param MetadataInterface $metadata
  *
  * @return Definition
  */
 protected function getMetadataDefinition(MetadataInterface $metadata)
 {
     $definition = new Definition(Metadata::class);
     $definition->setFactory([new Reference('sylius.resource_registry'), 'get'])->setArguments([$metadata->getAlias()]);
     return $definition;
 }