/** * 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 PcPlancakeEmailAddress $value A PcPlancakeEmailAddress object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(PcPlancakeEmailAddress $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getUserId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Generate and store a Plancake Email address * */ public function generateAndStorePlancakeEmailAddress() { do { $truncatedUserEmail = preg_replace('/@.*$/', '', $this->getEmail()); $randomPart = mt_rand(10, 99) . chr(mt_rand(97, 122)) . mt_rand(100, 999); $plancakeEmailAddressWithoutDomain = 'inbox_' . $truncatedUserEmail . '_' . $randomPart; // I double check the email address doesn't exist already $c = new Criteria(); $c->add(PcPlancakeEmailAddressPeer::EMAIL, $plancakeEmailAddressWithoutDomain, Criteria::EQUAL); $entry = PcPlancakeEmailAddressPeer::doSelectOne($c); } while (is_object($entry)); $plancakeEmailDbEntry = new PcPlancakeEmailAddress(); $plancakeEmailDbEntry->setUserId($this->getId())->setEmail($plancakeEmailAddressWithoutDomain)->save(); }
/** * Sets a single PcPlancakeEmailAddress object as related to this object by a one-to-one relationship. * * @param PcPlancakeEmailAddress $l PcPlancakeEmailAddress * @return PcUser The current object (for fluent API support) * @throws PropelException */ public function setPcPlancakeEmailAddress(PcPlancakeEmailAddress $v) { $this->singlePcPlancakeEmailAddress = $v; // Make sure that that the passed-in PcPlancakeEmailAddress isn't already associated with this object if ($v->getPcUser() === null) { $v->setPcUser($this); } return $this; }