【问题标题】:sulu CMS admin ui not showing datasulu CMS admin ui 不显示数据
【发布时间】:2023-01-24 05:42:52
【问题描述】:

我正在尝试显示来自控制器的列表,所有路由都在加载但数据未显示


    #[Route(path: '/admin/api/products', methods: ['GET'], name: 'app.get_products')]
    public function index(ManagerRegistry $doctrine): Response
    {
        $products = $doctrine->getRepository(Product::class)->findAll();   

        if (!$products) {
            return $this->json('No product found');
        }

        $data = [
            '_embedded' => [
                'products' => $products
            ]
        ];
   
        return $this->json($data);
    }

enter image description here

<?xml version="1.0" ?>
<list xmlns="http://schemas.sulu.io/list-builder/list">
    <key>products</key>
    <properties>
        <property name="id" visibility="no" translation="sulu_admin.id">
            <field-name>id</field-name>
            <entity-name>App\Entity\Product</entity-name>
        </property>

        <property name="Product" visibility="always" searchability="yes" type="string">
            <field-name>Product</field-name>
            <entity-name>App\Entity\Product</entity-name>
        </property>
        
        <property name="item_number" visibility="always" type="string">
            <field-name>ItemNumber</field-name>
            <entity-name>App\Entity\Product</entity-name>
        </property>

        <property name="quantity" visibility="always" type="integer">
            <field-name>quantity</field-name>
            <entity-name>App\Entity\Product</entity-name>
        </property>
    </properties>
</list>

我尝试使用 DoctrineRepresentational 工厂但显示未定义。

有什么我想念的吗?

【问题讨论】:

    标签: php symfony sulu


    【解决方案1】:

    您可能想要检查 Sulu Workshop 存储库并逐步完成不同的 Pull Requests 以跟进。这在开发我的第一个自定义实体时帮助了我:https://github.com/sulu/sulu-workshop/pulls

    例如,Sulu 人使用自定义的 DoctrineListRepresentationFactory 类,它通过 DoctrineListBuilder 返回一个 PaginatedRepresentation。我假设您的代码不起作用,因为 JSON 响应与 Sulu 管理员的预期不匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多