Check if ArrayCollection is empty

后端 未结 2 967
不知归路
不知归路 2021-02-02 08:24

I have an Entity Order which hold Suppliers in an Arraycollection. In my controller i want to check if this arraycollection is empty:

$suppliers = $order->get         


        
2条回答
  •  逝去的感伤
    2021-02-02 09:28

    Doctrine ArrayCollection has a method isEmpty that will do what you are looking for.

    if ($suppliers->isEmpty()) { }
    

    Take a look at the documentation for it here

提交回复
热议问题