예제 #1
0
 public function postActivation(ConnectionInterface $con = null)
 {
     try {
         DealerTeamQuery::create()->findOne();
     } catch (\Exception $e) {
         $database = new Database($con);
         $database->insertSql(null, [__DIR__ . "/Config/thelia.sql"]);
     }
     $this->addResource(self::RESOURCES_TEAM);
 }
예제 #2
0
 public function onTeamNavBar(HookRenderEvent $event)
 {
     $query = DealerTeamQuery::create();
     $joinPerson = new Join(DealerTeamTableMap::TEAM_ID, PersonTeamLinkTableMap::TEAM_ID, Criteria::LEFT_JOIN);
     $query->addJoinObject($joinPerson)->where(PersonTeamLinkTableMap::PERSON_ID . " " . Criteria::EQUAL . " " . $event->getArgument("person_id"));
     $dealer = $query->findOne();
     $args = $event->getArguments();
     if (null != $dealer) {
         $args["dealer_id"] = $dealer->getDealerId();
     }
     $event->add($this->render("includes/person-edit-link.html", $args));
 }
 /**
  * Get the associated ChildDealerTeam object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildDealerTeam The associated ChildDealerTeam object.
  * @throws PropelException
  */
 public function getDealerTeam(ConnectionInterface $con = null)
 {
     if ($this->aDealerTeam === null && $this->id !== null) {
         $this->aDealerTeam = ChildDealerTeamQuery::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->aDealerTeam->addDealerTeamVersions($this);
            */
     }
     return $this->aDealerTeam;
 }
예제 #4
0
 /**
  * Checks whether the current state must be recorded as a version
  *
  * @return  boolean
  */
 public function isVersioningNecessary($con = null)
 {
     if ($this->alreadyInSave) {
         return false;
     }
     if ($this->enforceVersion) {
         return true;
     }
     if (ChildDealerTeamQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
         return true;
     }
     if (null !== ($object = $this->getDealer($con)) && $object->isVersioningNecessary($con)) {
         return true;
     }
     return false;
 }
 protected function hydrateObjectArray($data, $locale = null)
 {
     $model = new DealerTeam();
     if (isset($data['id'])) {
         $link = DealerTeamQuery::create()->findOneById($data['id']);
         if ($link) {
             $model = $link;
         }
     }
     if (isset($data["team_id"]) && isset($data["dealer_id"])) {
         $link = DealerTeamQuery::create()->filterByDealerId($data["dealer_id"])->filterByTeamId($data["team_id"])->findOne();
         if ($link) {
             throw new \Exception("A link already exist", 403);
         }
         $model->setTeamId($data["team_id"]);
         $model->setDealerId($data["dealer_id"]);
     }
     return $model;
 }
 /**
  * Performs an INSERT on the database, given a DealerTeam or Criteria object.
  *
  * @param mixed               $criteria Criteria or DealerTeam 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(DealerTeamTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from DealerTeam object
     }
     if ($criteria->containsKey(DealerTeamTableMap::ID) && $criteria->keyContainsValue(DealerTeamTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . DealerTeamTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = DealerTeamQuery::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;
 }