/** * * remove a connection between elements * * @param Connection $connection */ public function removeConnection(Connection $connection) { foreach ($this->elements['connections'] as $key => $conn) { if ($conn->getId() == $connection->getId()) { unset($this->elements['connections'][$key]); // remove connection from element incoming connections and from outgoing connections $connection->getStartElement()->removeOutgoingConnection($connection); $connection->getEndElement()->removeIncomingConnection($connection); return true; } } throw new \Exception("Connection not found", 404); }
/** * * Remove an incoming connection * * @param Connection $connection * @return true || exception if does not exist */ public function removeIncomingConnection(Connection $connection) { foreach ($this->incomingConnections as $key => $conn) { if ($conn->getId() == $connection->getId()) { unset($this->incomingConnections[$key]); return true; } } throw new \Exception("Incoming connection does not exist", 404); }