示例#1
0
 /**
  * @param $groups UserGroup[]
  */
 public function ChangeGroups($groups)
 {
     $diff = new ArrayDiff($this->groups, $groups);
     $added = $diff->GetAddedToArray1();
     $removed = $diff->GetRemovedFromArray1();
     /** @var $group UserGroup */
     foreach ($added as $group) {
         $this->_addedGroups[] = $group;
     }
     /** @var $group UserGroup */
     foreach ($removed as $group) {
         $this->_removedGroups[] = $group;
     }
     $this->WithGroups($groups);
 }
示例#2
0
 /**
  * @param $attributes AttributeValue[]|array
  */
 public function ChangeAttributes($attributes)
 {
     $diff = new ArrayDiff($this->attributeValues, $attributes);
     $added = $diff->GetAddedToArray1();
     $removed = $diff->GetRemovedFromArray1();
     /** @var $attribute AttributeValue */
     foreach ($added as $attribute) {
         $this->addedAttributeValues[] = $attribute;
     }
     /** @var $accessory AttributeValue */
     foreach ($removed as $attribute) {
         $this->removedAttributeValues[] = $attribute;
     }
     foreach ($attributes as $attribute) {
         $this->AddAttributeValue($attribute);
     }
 }
示例#3
0
文件: Group.php 项目: hugutux/booked
 /**
  * @param $roleIds int[]|array
  * @return void
  */
 public function ChangeRoles($roleIds)
 {
     $diff = new ArrayDiff($this->roleIds, $roleIds);
     $removed = $diff->GetRemovedFromArray1();
     $added = $diff->GetAddedToArray1();
     if ($diff->AreDifferent()) {
         $this->rolesChanged = true;
         $this->removedRoleIds = $removed;
         $this->addedRoleIds = $added;
         $this->roleIds = $roleIds;
     }
 }
 /**
  * @param $attributes AttributeValue[]|array
  */
 public function ChangeAttributes($attributes)
 {
     $diff = new ArrayDiff($this->_attributeValues, $attributes);
     $added = $diff->GetAddedToArray1();
     $removed = $diff->GetRemovedFromArray1();
     /** @var $attribute AttributeValue */
     foreach ($added as $attribute) {
         $this->AddEvent(new AttributeAddedEvent($attribute, $this));
     }
     /** @var $accessory ReservationAccessory */
     foreach ($removed as $attribute) {
         $this->AddEvent(new AttributeRemovedEvent($attribute, $this));
     }
     $this->_attributeValues = array();
     foreach ($attributes as $attribute) {
         $this->AddAttributeValue($attribute);
     }
 }
示例#5
0
 /**
  * @param array|int[] $inviteeIds
  * @return int
  */
 public function ChangeInvitees($inviteeIds)
 {
     $diff = new ArrayDiff($this->_inviteeIds, $inviteeIds);
     $this->addedInvitees = $diff->GetAddedToArray1();
     $this->removedInvitees = $diff->GetRemovedFromArray1();
     $this->unchangedInvitees = $diff->GetUnchangedInArray1();
     $this->_inviteeIds = $inviteeIds;
     return count($this->addedInvitees) + count($this->removedInvitees);
 }