예제 #1
0
 /**
  * Merge this slot with one defined internally to the system.
  * Any updates to the internal storage will be made based on the external data.
  * 
  * @param object Slot $intSlot
  * @return void
  * @access public
  * @since 8/14/07
  */
 public final function mergeWithInternal(Slot $intSlot)
 {
     if ($this->getShortname() != $intSlot->getShortname()) {
         throw new Exception("Cannot merge slots with differing shortnames. '" . $this->getShortname() . "' != '" . $intSlot->getShortname() . "'");
     }
     if ($intSlot->isAlias()) {
         $this->populateAlias($intSlot->getAliasTarget()->getShortname());
     } else {
         $this->populateSiteId($intSlot->getSiteId());
     }
     foreach ($this->getOwners() as $key => $ownerId) {
         // If this owner was intentionally removed, don't list them.
         if ($intSlot->isRemovedOwner($ownerId)) {
             unset($this->owners[$key]);
         } else {
             if (!$intSlot->isOwner($ownerId)) {
                 $this->addOwner($ownerId);
             }
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     // Add owners that only appear in the internal slot
     foreach ($intSlot->getOwners() as $ownerId) {
         // If this owner was intentionally removed, populate that
         if (!$this->isOwner($ownerId)) {
             $this->populateOwnerId($ownerId);
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     // Add in "Removed owners" that only appear in the internal slot
     foreach ($intSlot->getRemovedOwners() as $ownerId) {
         // If this owner was intentionally removed, populate that
         if (!$this->isRemovedOwner($ownerId)) {
             $this->populateRemovedOwnerId($ownerId);
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     $this->isInDB = true;
 }