Example #1
0
 /**
  * Adds trust between the two local nodes i.e. FROM trusts TO
  * 
  * @param P2POwnNode $from
  * @param P2POwnNode $to
  */
 protected function runLocal(P2POwnNode $from, P2POwnNode $to)
 {
     // Look up the trust type, using default if necessary
     $typeName = $this->opts->{'trust-type'};
     $typeName = $typeName ? $typeName : MeshingTrustLocalPeer::TYPE_DEFAULT;
     $trustType = MeshingTrustTypeQuery::create()->findOneByName(strtolower($typeName));
     if (!$trustType) {
         throw new Meshing_Console_RunException('The specified trust type is not found');
     }
     // If a trust already exists, require force else an exception is thrown
     $trust = MeshingTrustLocalPeer::retrieveByPK($from->getId(), $to->getId());
     if ($trust) {
         if ($this->opts->force) {
             $trust->delete();
         } else {
             throw new Meshing_Console_RunException('A trust relationship already exists between this node pair (use --force to overwrite)');
         }
     }
     $trust = new MeshingTrustLocal();
     $trust->setFromOwnNode($from);
     $trust->setToOwnNode($to);
     $trust->setMeshingTrustType($trustType);
     $trust->save();
     if (!$this->opts->quiet) {
         echo "trust:add -> set up trust '{$typeName}' by node '{$from->getName()}' to '{$to->getName()}'.\n";
     }
 }
 /**
  * Exclude object from result
  *
  * @param     MeshingTrustLocal $meshingTrustLocal Object to remove from the list of results
  *
  * @return    MeshingTrustLocalQuery The current query, for fluid interface
  */
 public function prune($meshingTrustLocal = null)
 {
     if ($meshingTrustLocal) {
         $this->addCond('pruneCond0', $this->getAliasedColName(MeshingTrustLocalPeer::FROM_OWN_NODE_ID), $meshingTrustLocal->getFromOwnNodeId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(MeshingTrustLocalPeer::TO_OWN_NODE_ID), $meshingTrustLocal->getToOwnNodeId(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }
 /**
  * Filter the query by a related MeshingTrustLocal object
  *
  * @param     MeshingTrustLocal $meshingTrustLocal  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    MeshingTrustTypeQuery The current query, for fluid interface
  */
 public function filterByMeshingTrustLocal($meshingTrustLocal, $comparison = null)
 {
     if ($meshingTrustLocal instanceof MeshingTrustLocal) {
         return $this->addUsingAlias(MeshingTrustTypePeer::ID, $meshingTrustLocal->getType(), $comparison);
     } elseif ($meshingTrustLocal instanceof PropelCollection) {
         return $this->useMeshingTrustLocalQuery()->filterByPrimaryKeys($meshingTrustLocal->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByMeshingTrustLocal() only accepts arguments of type MeshingTrustLocal or PropelCollection');
     }
 }