arraycollection

Why does Flex's ArrayCollection's Contain method look at memory reference?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 16:10:29
When using .contains() on an ArrayCollection in Flex, it will always look at the memory reference. It does not appear to look at an .equals() method or .toString() method or anything overridable. Instead, I need to loop through the ArrayCollection every time and check each individual item until I find what I'm looking for. Does anyone know why Flex/ActionScript was made this way? Why not provide a way from people to use the contains() method the way they want? Couldn't you just extend ArrayCollection and override the contains() method? Alternatively you can paste the source for ArrayCollection

Check if ArrayCollection is empty

≡放荡痞女 提交于 2019-12-03 09:12:33
问题 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? 回答1: 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 回答2: You can also use the count() PHP function: if (count($suppliers) < 1) { } 来源: https:/

Check if ArrayCollection is empty

眉间皱痕 提交于 2019-12-02 23:43:46
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? Ken Hannel 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 You can also use the count() PHP function: if (count($suppliers) < 1) { } 来源: https://stackoverflow.com/questions/17643047/check-if-arraycollection-is-empty

Doctrine2 ArrayCollection

纵然是瞬间 提交于 2019-12-02 06:34:21
问题 Ok, I have a User entity as follows <?php class User { /** * @var integer * @Id * @Column(type="integer") * @GeneratedValue */ protected $id; /** * @var \Application\Entity\Url[] * @OneToMany(targetEntity="Url", mappedBy="user", cascade={"persist", "remove"}) */ protected $urls; public function __construct() { $this->urls = new \Doctrine\Common\Collections\ArrayCollection(); } public function addUrl($url) { // This is where I have a problem } } Now, what I want to do is check if the User has

Merge data into filtered ArrayCollection (maybe by using IViewCursor or localIndex?)

狂风中的少年 提交于 2019-12-01 13:49:01
I have a Flex question, which isn't as easy as it seems at first. At least I'm struggling since 1 week with it. I have prepared a test case and a screenshot. The question is: how do you merge data (coming repeatedly from server) into a filtered ArrayCollection? The screenshot: The TestCase.mxml (just place it into a Flash Builder 4.6 project): <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Declarations> <s:RadioButtonGroup id="_group" itemClick="radioClicked(event);"/> </fx:Declarations> <fx:Script

How to merge two php Doctrine 2 ArrayCollection()

a 夏天 提交于 2019-11-28 04:36:46
Is there any convenience method that allows me to concatenate two Doctrine ArrayCollection() ? something like: $collection1 = new ArrayCollection(); $collection2 = new ArrayCollection(); $collection1->add($obj1); $collection1->add($obj2); $collection1->add($obj3); $collection2->add($obj4); $collection2->add($obj5); $collection2->add($obj6); $collection1->concat($collection2); // $collection1 now contains {$obj1, $obj2, $obj3, $obj4, $obj5, $obj6 } I just want to know if I can save me iterating over the 2nd collection and adding each element one by one to the 1st collection. Thanks! Better (and

Doctrine 2 ArrayCollection filter method

狂风中的少年 提交于 2019-11-27 11:05:40
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 me how the filter method is actually used. FredRoger The Boris Guéry answer's at this post, may help you: Doctrine 2, query inside entities $idsToFilter = array(1,2,3,4); $member->getComments()->filter( function($entry) use ($idsToFilter) { return in_array($entry->getId(), $idsToFilter); } ); Ryan Doctrine now has Criteria which offers a single API

How to merge two php Doctrine 2 ArrayCollection()

亡梦爱人 提交于 2019-11-27 00:32:58
问题 Is there any convenience method that allows me to concatenate two Doctrine ArrayCollection() ? something like: $collection1 = new ArrayCollection(); $collection2 = new ArrayCollection(); $collection1->add($obj1); $collection1->add($obj2); $collection1->add($obj3); $collection2->add($obj4); $collection2->add($obj5); $collection2->add($obj6); $collection1->concat($collection2); // $collection1 now contains {$obj1, $obj2, $obj3, $obj4, $obj5, $obj6 } I just want to know if I can save me

Doctrine 2 ArrayCollection filter method

荒凉一梦 提交于 2019-11-26 17:59:12
问题 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 me how the filter method is actually used. 回答1: The Boris Guéry answer's at this post, may help you: Doctrine 2, query inside entities $idsToFilter = array(1,2,3,4); $member->getComments()->filter( function($entry) use ($idsToFilter) { return in