1# --
2# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
3# --
4# This software comes with ABSOLUTELY NO WARRANTY. For details, see
5# the enclosed file COPYING for license information (GPL). If you
6# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
7# --
8
9package Kernel::GenericInterface::Event::ObjectType::DynamicField;
10
11use strict;
12use warnings;
13
14use Kernel::System::VariableCheck qw(:all);
15
16our @ObjectDependencies = (
17    'Kernel::System::Log',
18    'Kernel::System::DynamicField',
19);
20
21=head1 NAME
22
23Kernel::GenericInterface::Event::ObjectType::DynamicField - GenericInterface event data handler
24
25=head1 SYNOPSIS
26
27This event handler gathers data from objects.
28
29=cut
30
31sub new {
32    my ( $Type, %Param ) = @_;
33
34    # Allocate new hash for object.
35    my $Self = {};
36    bless( $Self, $Type );
37
38    return $Self;
39}
40
41sub DataGet {
42    my ( $Self, %Param ) = @_;
43
44    for my $Needed (qw(Data)) {
45        if ( !$Param{$Needed} ) {
46            $Kernel::OM->Get('Kernel::System::Log')->Log(
47                Priority => 'error',
48                Message  => "Need $Needed!"
49            );
50            return;
51        }
52    }
53
54    my $ID = $Param{Data}->{NewData}->{ID};
55
56    if ( !$ID ) {
57        $Kernel::OM->Get('Kernel::System::Log')->Log(
58            Priority => 'error',
59            Message  => "Need NewData->ID!",
60        );
61        return;
62    }
63
64    my $ObjectData = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(
65        ID => $ID,
66    );
67
68    return %{$ObjectData};
69}
70
711;
72
73=head1 TERMS AND CONDITIONS
74
75This software is part of the OTRS project (L<https://otrs.org/>).
76
77This software comes with ABSOLUTELY NO WARRANTY. For details, see
78the enclosed file COPYING for license information (GPL). If you
79did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
80
81=cut
82