Passed
Push — main ( 3919a2...0705b8 )
by Iain
15:39
created

SubscriptionSection::getMenuName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Athena;
16
17
use Parthenon\Athena\AbstractSection;
18
use Parthenon\Athena\Button;
19
use Parthenon\Athena\ListView;
20
use Parthenon\Athena\ReadView;
21
use Parthenon\Athena\Repository\CrudRepositoryInterface;
22
use Parthenon\Athena\Settings;
23
use Parthenon\Billing\Entity\Subscription;
24
use Parthenon\Billing\Repository\SubscriptionRepositoryInterface;
25
26
class SubscriptionSection extends AbstractSection
27
{
28
    public function __construct(private SubscriptionRepositoryInterface $subscriptionRepository)
29
    {
30
    }
31
32
    public function buildListView(ListView $listView): ListView
33
    {
34
        $listView->addField('customer', 'text')
35
            ->addField('planName', 'text')
36
            ->addField('status', 'text')
37
            ->addField('validUntil', 'text');
38
39
        return $listView;
40
    }
41
42
    public function buildReadView(ReadView $readView): ReadView
43
    {
44
        $readView->section('Main')
45
                ->field('planName')
46
                ->field('createdAt')
47
                ->field('validUntil')
48
            ->end();
49
50
        return $readView;
51
    }
52
53
    public function getButtons(): array
54
    {
55
        return [
56
            new Button('subscription_cancel', 'Cancel Subscription', 'parthenon_billing_athena_subscription_cancel'),
57
        ];
58
    }
59
60
    public function getSettings(): Settings
61
    {
62
        return new Settings(['create' => false, 'edit' => false]);
63
    }
64
65
    public function getUrlTag(): string
66
    {
67
        return 'subscriptions';
68
    }
69
70
    public function getRepository(): CrudRepositoryInterface
71
    {
72
        return $this->subscriptionRepository;
73
    }
74
75
    public function getEntity()
76
    {
77
        return new Subscription();
78
    }
79
80
    public function getMenuSection(): string
81
    {
82
        return 'Billing';
83
    }
84
85
    public function getMenuName(): string
86
    {
87
        return 'Subscriptions';
88
    }
89
}
90