Exemplo n.º 1
0
 /**
  * @param ResourceInterface $resource
  * @param string|null       $name
  *
  * @return ArrayNodeDefinition
  */
 private function createResourceNode(ResourceInterface $resource, $name = null)
 {
     $resourceNode = $this->createNode($name ?: $resource->getName())->addDefaultsIfNotSet();
     $childrenNode = $resourceNode->children()->append($this->createClassNode('model', $resource->getModel(), $resource->getInterfaces(), true))->append($this->createDriverNode($resource))->append($this->createClassNode('repository', $resource->getRepository(), [RepositoryInterface::class]))->append($this->createClassNode('factory', $resource->getFactory(), [FactoryInterface::class]))->append($this->createClassNode('form', $resource->getForm(), [FormTypeInterface::class]))->append($this->createClassNode('choice_form', $resource->getChoiceForm(), [FormTypeInterface::class]))->append($this->createClassNode('domain_manager', $resource->getDomainManager(), [DomainManagerInterface::class]))->append($this->createClassNode('controller', $resource->getController(), [ControllerInterface::class]))->append($this->createNode('id_property_path', 'scalar', $resource->getIdPropertyPath()))->append($this->createNode('label_property_path', 'scalar', $resource->getLabelPropertyPath()));
     foreach ($resource->getRelations() as $name => $relation) {
         $childrenNode->append($this->createResourceNode($relation, $name));
     }
     return $resourceNode;
 }
Exemplo n.º 2
0
 /**
  * @param ResourceInterface $resource
  *
  * @return Definition
  */
 private function createResourceDefinition(ResourceInterface $resource)
 {
     $definition = new Definition(Resource::class, [$resource->getName(), $resource->getInterfaces(), $resource->getModel()]);
     $definition->addMethodCall('setDriver', [$resource->getDriver()])->addMethodCall('setDriverManager', [$resource->getDriverManager()])->addMethodCall('setDriverMappingPath', [$resource->getDriverMappingPath()])->addMethodCall('setDriverMappingFormat', [$resource->getDriverMappingFormat()])->addMethodCall('setRepository', [$resource->getRepository()])->addMethodCall('setFactory', [$resource->getFactory()])->addMethodCall('setForm', [$resource->getForm()])->addMethodCall('setChoiceForm', [$resource->getChoiceForm()])->addMethodCall('setDomainManager', [$resource->getDomainManager()])->addMethodCall('setController', [$resource->getController()])->addMethodCall('setIdPropertyPath', [$resource->getIdPropertyPath()])->addMethodCall('setLabelPropertyPath', [$resource->getLabelPropertyPath()])->addTag('lug.resource');
     foreach ($resource->getRelations() as $name => $relation) {
         $definition->addMethodCall('addRelation', [$name, new Reference('lug.resource.' . $relation->getName())]);
     }
     return $definition;
 }
Exemplo n.º 3
0
 /**
  * @param ResourceInterface $resource
  *
  * @return Definition
  */
 private function createResourceDefinition(ResourceInterface $resource)
 {
     $arguments = [$resource->getName(), $resource->getDriver(), $resource->getDriverManager(), $resource->getDriverMappingPath(), $resource->getDriverMappingFormat(), $resource->getInterfaces(), $resource->getModel(), $resource->getController(), $resource->getFactory(), $resource->getRepository(), $resource->getDomainManager(), $resource->getForm(), $resource->getChoiceForm(), $resource->getIdPropertyPath(), $resource->getLabelPropertyPath()];
     if ($resource->getTranslation() !== null) {
         $arguments[] = new Reference('lug.resource.' . $resource->getTranslation()->getName());
     }
     $definition = new Definition(Resource::class, $arguments);
     $definition->addTag('lug.resource');
     return $definition;
 }