From 92d36a4039874c9aa4ae0ca8b0c1553852de788b Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 20 Dec 2015 11:20:16 -0800 Subject: [PATCH] _getOrCreateRequestConfiguration: Implement. Implementation of this method. --- Supporters/lib/Supporters.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 6b5c491..a8a286e 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -637,6 +637,21 @@ sub _getOrCreateRequestConfiguration($$) { die "_getOrCreateRequestConfiguration: requestTypeId must be a number" unless looks_like_number($requestTypeId); die "_getOrCreateRequestConfiguration: requestTypeId is unknown" unless $self->_verifyRequestTypeId($requestTypeId); + if (not defined $params->{requestConfigurationId}) { + $params->{requestConfigurationId} = $self->addRequestType($params->{requestConfiguration}); + } else { + my $id = $params->{requestConfigurationId}; + die "_getOrCreateRequestConfiguration(): called with a non-numeric requestConfigurationId, \"$id\"" + unless defined $id and looks_like_number($id); + + my $val = $self->dbh()->selectall_hashref("SELECT id FROM request_configuration WHERE id = " . + $self->dbh->quote($id, 'SQL_INTEGER'), 'id'); + + die "_getOrCreateRequestType(): given requestConfigurationId, \"$id\", is invalid" + unless (defined $val and defined $val->{$id}); + } + delete $params->{requestConfiguration}; + return $params->{requestConfigurationId}; } =item _beginWork()