Questions tagged [arraycollection]

The ArrayCollection class is a wrapper class that exposes an Array as a collection in Flex which can be accessed and manipulated. Use this tag for questions related to arraycollection.

The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces. Operations on a ArrayCollection instance modify the data source; for example, if you use the removeItemAt() method on an ArrayCollection, you remove the item from the underlying Array.

Reference

340 questions
95
votes
10 answers

How to merge two php Doctrine 2 ArrayCollection()

Is there any convenience method that allows me to concatenate two Doctrine ArrayCollection()? something like: $collection1 = new ArrayCollection(); $collection2 = new…
Throoze
  • 3,988
  • 8
  • 45
  • 67
72
votes
5 answers

Doctrine 2 ArrayCollection filter method

Can I filter out results from an arrayCollection in Doctrine 2 while using lazy loading? For example, // users = ArrayCollection with User entities containing an "active" property $customer->users->filter('active' => TRUE)->first() It's unclear for…
Dennis
  • 3,448
  • 8
  • 38
  • 45
32
votes
2 answers

Check if ArrayCollection is empty

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->getSuppliers(); I tried: if(!($suppliers)) {} if(empty($suppliers)) {} Any ideas?
ChrisS
  • 736
  • 2
  • 8
  • 21
16
votes
2 answers

Order of Symfony form CollectionType field

In my model I have a Recipe entity and Ingredient entity. In Recipe entity, the relation is defined like this: /** * @ORM\OneToMany(targetEntity="Ingredient", mappedBy="recipe", cascade={"remove", "persist"}, orphanRemoval=true) *…
Karolis
  • 2,580
  • 2
  • 16
  • 31
15
votes
1 answer

Doctrine2: check if exists value in Doctrine Collection

How can I check that given value exists in Doctrine Collection (ManyToMany relation) field? For example I try to: $someClass = $this-> getDoctrine()-> getRepository('MyBundle:MyClass')-> find($id); if…
spiilmusic
  • 717
  • 3
  • 9
  • 24
10
votes
1 answer

Symfony2: How to remove an element from a Doctrine ArrayCollection (many-to-many relation)?

I use the following code for my many-to-many relation in symfony2 (doctrine) Entity: /** * @ORM\ManyToMany(targetEntity="BizTV\ContainerManagementBundle\Entity\Container", inversedBy="videosToSync") * @ORM\JoinTable(name="syncSchema") */ private…
Matt Welander
  • 8,234
  • 24
  • 88
  • 138
9
votes
4 answers

Arraycollection is being passed into function by value instead of by reference in flex 3

I want to set arrayCollection #2 = to arrayCollection #1 via a function in flex 3. I pass both array collections to a function and set arrayCollection #2 = arrayCollection #1. However, it seems to not be passing arrayCollection #2 by reference…
Steven
  • 1,949
  • 2
  • 17
  • 30
8
votes
3 answers

PHP Doctrine : Test if an object is in an ArrayCollection

I am trying to use the method ArrayCollection::contains to find if an object is already in my Collection, but when i am doing : //My ArrayCollection $lesRoles = $drt->getDrtApplication()->getRoles(); $leRole = $lesRoles->first(); echo "Property…
7
votes
2 answers

Convert Vector. to Array?

Unfortunately in Actionscript, it seems like support for the Vector class isn't fully there yet. There are some scenarios where I need to convert a Vector into an array (creating an ArrayCollection for example). I thought this would do the…
Ocelot20
  • 10,510
  • 11
  • 55
  • 96
6
votes
2 answers

Doctrine 2.1: How to orderBy aggregate field in a collection?

I have an entity with a ArrayCollection field. In the annotations I can write @ORM\OrderBy({"somefield" = "DESC"}) and the collection I get from that entity will be automatically ordered. My question is if it is possible to order by aggregate…
Tony Bogdanov
  • 7,436
  • 10
  • 49
  • 80
6
votes
2 answers

doctrine ORM count arraycollection in where condition

Using Symfony2.8 with Doctrine 2.5, I want to filter in a Doctrine ORM query all datasets where the arraycollection contains exactly 3 elements. $em = $this->getDoctrine()->getManager(); $query =…
Immanuel
  • 61
  • 1
  • 3
6
votes
1 answer

ArrayCollection in Symfony

since I'm quite new to Symfony and Doctrine I got a maybe stupid question ;-) Can someone use simple words to explain Collections (especially ArrayCollections in entities) to me? What is it and when and how to use them? (Maybe in an simple…
Felix2000
  • 85
  • 1
  • 1
  • 6
6
votes
1 answer

Map a form's text field to an entity's ArrayCollection

I am using tags on a form using tagsinput : This plugin ends-up with a single text field containing tags separated by a comma (eg: tag1,tag2,...) Those tags are currently managed on a non-mapped form field: $builder // ... …
Alain Tiemblo
  • 36,099
  • 17
  • 121
  • 153
6
votes
1 answer

Doctrine2 doesn't load Collection until a method is called

When does Doctrine2 loads the ArrayCollection? Until I call a method, like count or getValues, I have no data Here is my case. I have a Delegation entity with OneToMany (bidirectional) relation to a Promotion Entity, like this: Promotion.php use…
hosseio
  • 1,142
  • 2
  • 12
  • 25
6
votes
4 answers

Passing an ArrayCollection from ColdFusion to Flex (with BlazeDS)

When pushing objects from ColdFusion to Flex via BlazeDS, and mapping the classes using RemoteClass... [RemoteClass(alias="blah.blah")] ...is it possible to have ColdFusion "Arrays" (or some Java equivalent) automatically mapped to ActionScript…
stubotnik
  • 1,952
  • 2
  • 17
  • 31
1
2 3
22 23