/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PermissionItem $value A PermissionItem object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PermissionItem $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 /**
  * Declares an association between this object and a PermissionItem object.
  *
  * @param      PermissionItem $v
  * @return     PermissionToPermissionItem The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setPermissionItem(PermissionItem $v = null)
 {
     if ($v === null) {
         $this->setPermissionItemId(NULL);
     } else {
         $this->setPermissionItemId($v->getId());
     }
     $this->aPermissionItem = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the PermissionItem object, it will not be re-added.
     if ($v !== null) {
         $v->addPermissionToPermissionItem($this);
     }
     return $this;
 }
function removeItemFromPermissions(PermissionItem $item, array $permissionNames)
{
    foreach ($permissionNames as $permissionName) {
        $partnerPermission = array_map('trim', explode('>', $permissionName));
        $partnerId = PartnerPeer::GLOBAL_PARTNER;
        if (count($partnerPermission) === 2) {
            $partnerId = trim($partnerPermission[0]);
        }
        $permissionName = trim(end($partnerPermission));
        $c = new Criteria();
        $c->addAnd(PermissionPeer::NAME, $permissionName);
        $c->addAnd(PermissionPeer::TYPE, array(PermissionType::NORMAL, PermissionType::PARTNER_GROUP), Criteria::IN);
        $c->addAnd(PermissionPeer::PARTNER_ID, array(PartnerPeer::GLOBAL_PARTNER, $item->getPartnerId(), $partnerId), Criteria::IN);
        $permission = PermissionPeer::doSelectOne($c);
        if (!$permission) {
            continue;
        }
        $c = new Criteria();
        $c->addAnd(PermissionToPermissionItemPeer::PERMISSION_ITEM_ID, $item->getId());
        $c->addAnd(PermissionToPermissionItemPeer::PERMISSION_ID, $permission->getId());
        $permissionToPermissionItem = PermissionToPermissionItemPeer::doSelectOne($c);
        if (!$permissionToPermissionItem) {
            continue;
        }
        $permissionToPermissionItem->delete();
    }
}
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PermissionItem $value A PermissionItem object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PermissionItem $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('PermissionItemPeer');
         }
     }
 }