GravityForms.php
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
declare(strict_types=1);
namespace ACA\GravityForms;
use AC;
use AC\DefaultColumnsRepository;
use AC\Registerable;
use AC\Services;
use AC\Vendor\Psr\Container\ContainerInterface;
use ACA\GravityForms\Search\Query;
use ACA\GravityForms\Service\ColumnGroup;
use ACA\GravityForms\Service\Scripts;
use ACP\Search\QueryFactory;
use ACP\Search\TableScreenFactory;
use ACP\Service\IntegrationStatus;
use GFCommon;
final class GravityForms implements Registerable
{
public const GROUP = 'gravity_forms';
private $location;
private $container;
public function __construct(AC\Asset\Location\Absolute $location, ContainerInterface $container)
{
$this->location = $location;
$this->container = $container;
}
public function register(): void
{
if ( ! class_exists('GFCommon', false)) {
return;
}
$minimum_gf_version = '2.5';
if (class_exists('GFCommon', false) && version_compare((string)GFCommon::$version, $minimum_gf_version, '<')) {
return;
}
AC\ListScreenFactory\Aggregate::add(new ListScreenFactory\EntryFactory());
$this->create_services()->register();
// Enable Search
QueryFactory::register(MetaTypes::GRAVITY_FORMS_ENTRY, Query::class);
TableScreenFactory::register(ListScreen\Entry::class, Search\TableScreen\Entry::class);
}
private function create_services(): Services
{
return new Services([
new Service\ListScreens(),
new TableScreen\Entry(
new AC\ListScreenFactory\Aggregate(),
$this->container->get(AC\ListScreenRepository\Storage::class),
new DefaultColumnsRepository()
),
new Admin(),
new IntegrationStatus('ac-addon-gravityforms'),
new Scripts($this->location),
new ColumnGroup(),
]);
}
}