/** * To determine if a store has all the Address from another store, it will expand AddressGroups instead of looking for them directly. Very useful when looking to compare similar rules. * @param AddressRuleContainer $other * @param bool $anyIsAcceptable if any of these objects is Any the it will return false * @return bool true if Address objects from $other are all in this store */ public function includesContainerExpanded(AddressRuleContainer $other, $anyIsAcceptable = true) { if (!$anyIsAcceptable) { if ($this->count() == 0 || $other->count() == 0) { return false; } } if ($this->count() == 0) { return true; } if ($other->count() == 0) { return false; } $localA = array(); $A = array(); foreach ($this->o as $object) { if ($object->isGroup()) { $flat = $object->expand(); $localA = array_merge($localA, $flat); } else { $localA[] = $object; } } $localA = array_unique_no_cast($localA); $otherAll = $other->all(); foreach ($otherAll as $object) { if ($object->isGroup()) { $flat = $object->expand(); $A = array_merge($A, $flat); } else { $A[] = $object; } } $A = array_unique_no_cast($A); $diff = array_diff_no_cast($A, $localA); if (count($diff) > 0) { return false; } return true; }