Lines 60-69
sub store {
Link Here
|
60 |
unless $type; |
60 |
unless $type; |
61 |
|
61 |
|
62 |
Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self ) |
62 |
Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self ) |
63 |
unless $self->repeatable_ok($type); |
63 |
unless $self->repeatable_ok(); |
64 |
|
64 |
|
65 |
Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self ) |
65 |
Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self ) |
66 |
unless $self->unique_ok($type); |
66 |
unless $self->unique_ok(); |
67 |
|
67 |
|
68 |
return $self->SUPER::store(); |
68 |
return $self->SUPER::store(); |
69 |
} |
69 |
} |
Lines 146-152
sub to_api_mapping {
Link Here
|
146 |
|
146 |
|
147 |
=head3 repeatable_ok |
147 |
=head3 repeatable_ok |
148 |
|
148 |
|
149 |
if ( $attr->repeatable_ok( $type ) ) { ... } |
149 |
if ( $attr->repeatable_ok() ) { ... } |
150 |
|
150 |
|
151 |
Checks if the attribute type is repeatable and returns a boolean representing |
151 |
Checks if the attribute type is repeatable and returns a boolean representing |
152 |
whether storing the current object state would break the repeatable constraint. |
152 |
whether storing the current object state would break the repeatable constraint. |
Lines 155-167
whether storing the current object state would break the repeatable constraint.
Link Here
|
155 |
|
155 |
|
156 |
sub repeatable_ok { |
156 |
sub repeatable_ok { |
157 |
|
157 |
|
158 |
my ( $self, $type ) = @_; |
158 |
my ( $self ) = @_; |
159 |
|
|
|
160 |
Koha::Exceptions::MissingParameter->throw( "The type parameter is mandatory" ) |
161 |
unless $type; |
162 |
|
159 |
|
163 |
my $ok = 1; |
160 |
my $ok = 1; |
164 |
if ( !$type->repeatable ) { |
161 |
if ( !$self->type->repeatable ) { |
165 |
my $params = { |
162 |
my $params = { |
166 |
borrowernumber => $self->borrowernumber, |
163 |
borrowernumber => $self->borrowernumber, |
167 |
code => $self->code |
164 |
code => $self->code |
Lines 178-184
sub repeatable_ok {
Link Here
|
178 |
|
175 |
|
179 |
=head3 unique_ok |
176 |
=head3 unique_ok |
180 |
|
177 |
|
181 |
if ( $attr->unique_ok( $type ) ) { ... } |
178 |
if ( $attr->unique_ok() ) { ... } |
182 |
|
179 |
|
183 |
Checks if the attribute type is marked as unique and returns a boolean representing |
180 |
Checks if the attribute type is marked as unique and returns a boolean representing |
184 |
whether storing the current object state would break the unique constraint. |
181 |
whether storing the current object state would break the unique constraint. |
Lines 187-199
whether storing the current object state would break the unique constraint.
Link Here
|
187 |
|
184 |
|
188 |
sub unique_ok { |
185 |
sub unique_ok { |
189 |
|
186 |
|
190 |
my ( $self, $type ) = @_; |
187 |
my ( $self ) = @_; |
191 |
|
|
|
192 |
Koha::Exceptions::MissingParameter->throw( "The type parameter is mandatory" ) |
193 |
unless $type; |
194 |
|
188 |
|
195 |
my $ok = 1; |
189 |
my $ok = 1; |
196 |
if ( $type->unique_id ) { |
190 |
if ( $self->type->unique_id ) { |
197 |
my $params = { code => $self->code, attribute => $self->attribute }; |
191 |
my $params = { code => $self->code, attribute => $self->attribute }; |
198 |
|
192 |
|
199 |
$params->{borrowernumber} = { '!=' => $self->borrowernumber } if $self->borrowernumber; |
193 |
$params->{borrowernumber} = { '!=' => $self->borrowernumber } if $self->borrowernumber; |