public function renderFile() { $bCleanup = Manager::usePath() === self::DO_CLEANUP; $aReferences = ReferenceQuery::create()->find(); self::checkReferences($aReferences, $bCleanup); if (count(self::$REFERENCES_WITHOUT_FROM) === 0 && count(self::$REFERENCES_WITHOUT_TO) === 0) { if (!$bCleanup) { print TranslationPeer::getString('test_references.references_are_ok', null, null, array('count' => count($aReferences))); } else { print TranslationPeer::getString('test_references.wrong_references_removed'); print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references'), 'FileManager')), TranslationPeer::getString('test_references.test_again'))); } } else { if (count(self::$REFERENCES_WITHOUT_FROM) > 0) { print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_FROM) . TranslationPeer::getString('test_references.loose_from_references_found')); foreach (self::$REFERENCES_WITHOUT_FROM as $oReference) { print TagWriter::quickTag('p', array(), $oReference->getFromModelName() . '/' . $oReference->getFromId()); } } if (count(self::$REFERENCES_WITHOUT_TO) > 0) { print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_TO) . TranslationPeer::getString('test_references.loose_to_references_found')); foreach (self::$REFERENCES_WITHOUT_TO as $oReference) { print TagWriter::quickTag('p', array(), $oReference->getToModelName() . '/' . $oReference->getToId()); } } print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references', self::DO_CLEANUP), 'FileManager')), TranslationPeer::getString('test_references.remove_loose_ends'))); } }
/** * Returns a new ReferenceQuery object. * * @param string $modelAlias The alias of a model in the query * @param ReferenceQuery|Criteria $criteria Optional Criteria to build the query from * * @return ReferenceQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ReferenceQuery) { return $criteria; } $query = new ReferenceQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Returns the number of related Reference objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Reference objects. * @throws PropelException */ public function countReferencesRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collReferencesRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collReferencesRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collReferencesRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getReferencesRelatedByUpdatedBy()); } $query = ReferenceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collReferencesRelatedByUpdatedBy); }
private static function prepareCriteria($mFromObject = null, $mToObject = null) { $oCriteria = ReferenceQuery::create(); if ($mFromObject !== null) { self::prepareCriteriaFrom($oCriteria, $mFromObject); } if ($mToObject !== null) { self::prepareCriteriaTo($oCriteria, $mToObject); } return $oCriteria; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ReferencePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ReferenceQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(ReferencePeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.custom", array("role_key" => "indirect_references"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }