/** * @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; }
/** * @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; }