]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1382085 - Add find_first_flag_type() to Bugzilla::Component
authorDylan William Hardison <dylan@hardison.net>
Wed, 19 Jul 2017 14:51:04 +0000 (10:51 -0400)
committerGitHub <noreply@github.com>
Wed, 19 Jul 2017 14:51:04 +0000 (10:51 -0400)
Bugzilla/Component.pm

index 83ddec356c4f2da093400ba43bc05da3e63d04fb..08a55846d778b32594c7689122ea6e493e4dd8a7 100644 (file)
@@ -20,6 +20,7 @@ use Bugzilla::User;
 use Bugzilla::FlagType;
 use Bugzilla::Series;
 
+use List::Util qw(first);
 use Scalar::Util qw(blessed);
 
 ###############################
@@ -405,6 +406,12 @@ sub flag_types {
     return $self->{'flag_types'};
 }
 
+sub find_first_flag_type {
+    my ($self, $target_type, $name) = @_;
+
+    return first { $_->name eq $name } @{ $self->flag_types->{$target_type} };
+}
+
 sub initial_cc {
     my $self = shift;
     my $dbh = Bugzilla->dbh;
@@ -609,6 +616,17 @@ Component.pm represents a Product Component object.
 
  Returns:     Nothing.
 
+
+=item C<find_first_flag_type($target_type, $name).
+
+ Description: Find the first named bug or attachment flag with a given
+              name on this component.
+
+ Params:      $target_type - 'bug' or 'attachment'
+              $name        - the name of the flag
+
+ Returns:     a new Bugzilla::FlagType object or undef
+
 =item C<set_description($new_desc)>
 
  Description: Changes the description of the component.