public function verifyProfileId($value, ExecutionContextInterface $context) { $profile = ProfileQuery::create()->findPk($value); if (null === $profile) { $context->addViolation(Translator::getInstance()->trans("Profile ID not found")); } }
public static function getProfileList() { $profileList = array(0 => AdminResources::SUPERADMINISTRATOR); foreach (ProfileQuery::create()->find() as $profile) { $profileList[$profile->getId()] = $profile->getCode(); } return $profileList; }
public function verifyCode($value, ExecutionContextInterface $context) { /* check unicity */ $profile = ProfileQuery::create()->findOneByCode($value); if (null !== $profile) { $context->addViolation(Translator::getInstance()->trans("Profile `code` already exists")); } }
public function buildModelCriteria() { $search = ProfileQuery::create(); /* manage translations */ $this->configureI18nProcessing($search); $id = $this->getId(); if (null !== $id) { $search->filterById($id, Criteria::IN); } $search->orderById(Criteria::ASC); return $search; }
/** * Gets the number of ChildProfile objects related by a many-to-many relationship * to the current object by way of the profile_resource cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * * @return int the number of related ChildProfile objects */ public function countProfiles($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collProfiles || null !== $criteria) { if ($this->isNew() && null === $this->collProfiles) { return 0; } else { $query = ChildProfileQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByResource($this)->count($con); } } else { return count($this->collProfiles); } }
public static function setUpBeforeClass() { ProfileQuery::create()->filterByCode('Test')->delete(); }
/** * Performs an INSERT on the database, given a Profile or Criteria object. * * @param mixed $criteria Criteria or Profile object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Profile object } if ($criteria->containsKey(ProfileTableMap::ID) && $criteria->keyContainsValue(ProfileTableMap::ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProfileTableMap::ID . ')'); } // Set the correct dbName $query = ProfileQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->beginTransaction(); $pk = $query->doInsert($con); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } return $pk; }
/** * Get the associated ChildProfile object * * @param ConnectionInterface $con Optional Connection object. * @return ChildProfile The associated ChildProfile object. * @throws PropelException */ public function getProfile(ConnectionInterface $con = null) { if ($this->aProfile === null && $this->id !== null) { $this->aProfile = ChildProfileQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aProfile->addProfileI18ns($this); */ } return $this->aProfile; }
protected function getExistingObject() { $profile = ProfileQuery::create()->findOneById($this->getRequest()->get('profile_id', 0)); if (null !== $profile) { $profile->setLocale($this->getCurrentEditionLocale()); } return $profile; }
/** * Removes this object from datastore and sets delete attribute. * * @param ConnectionInterface $con * @return void * @throws PropelException * @see Profile::setDeleted() * @see Profile::isDeleted() */ public function delete(ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $deleteQuery = ChildProfileQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * @param ProfileEvent $event */ public function delete(ProfileEvent $event) { if (null !== ($profile = ProfileQuery::create()->findPk($event->getId()))) { $profile->delete(); $event->setProfile($profile); } }