Skip to content

Commit a8be822

Browse files
committed
[WIP] Files generated by Phpstorm
1 parent e60b0ad commit a8be822

31 files changed

+1717
-0
lines changed

Api/Data/AsyncEventInterface.php

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace MageOS\AsyncEventsAdminUi\Api\Data;
5+
6+
interface AsyncEventInterface
7+
{
8+
/**
9+
* String constants for property names
10+
*/
11+
public const SUBSCRIPTION_ID = "subscription_id";
12+
public const EVENT_NAME = "event_name";
13+
public const RECIPIENT_URL = "recipient_url";
14+
public const VERIFICATION_TOKEN = "verification_token";
15+
public const STATUS = "status";
16+
public const METADATA = "metadata";
17+
public const STORE_ID = "store_id";
18+
19+
/**
20+
* Getter for SubscriptionId.
21+
*
22+
* @return int|null
23+
*/
24+
public function getSubscriptionId(): ?int;
25+
26+
/**
27+
* Setter for SubscriptionId.
28+
*
29+
* @param int|null $subscriptionId
30+
*
31+
* @return void
32+
*/
33+
public function setSubscriptionId(?int $subscriptionId): void;
34+
35+
/**
36+
* Getter for EventName.
37+
*
38+
* @return string|null
39+
*/
40+
public function getEventName(): ?string;
41+
42+
/**
43+
* Setter for EventName.
44+
*
45+
* @param string|null $eventName
46+
*
47+
* @return void
48+
*/
49+
public function setEventName(?string $eventName): void;
50+
51+
/**
52+
* Getter for RecipientUrl.
53+
*
54+
* @return string|null
55+
*/
56+
public function getRecipientUrl(): ?string;
57+
58+
/**
59+
* Setter for RecipientUrl.
60+
*
61+
* @param string|null $recipientUrl
62+
*
63+
* @return void
64+
*/
65+
public function setRecipientUrl(?string $recipientUrl): void;
66+
67+
/**
68+
* Getter for VerificationToken.
69+
*
70+
* @return string|null
71+
*/
72+
public function getVerificationToken(): ?string;
73+
74+
/**
75+
* Setter for VerificationToken.
76+
*
77+
* @param string|null $verificationToken
78+
*
79+
* @return void
80+
*/
81+
public function setVerificationToken(?string $verificationToken): void;
82+
83+
/**
84+
* Getter for Status.
85+
*
86+
* @return bool|null
87+
*/
88+
public function getStatus(): ?bool;
89+
90+
/**
91+
* Setter for Status.
92+
*
93+
* @param bool|null $status
94+
*
95+
* @return void
96+
*/
97+
public function setStatus(?bool $status): void;
98+
99+
/**
100+
* Getter for Metadata.
101+
*
102+
* @return string|null
103+
*/
104+
public function getMetadata(): ?string;
105+
106+
/**
107+
* Setter for Metadata.
108+
*
109+
* @param string|null $metadata
110+
*
111+
* @return void
112+
*/
113+
public function setMetadata(?string $metadata): void;
114+
115+
/**
116+
* Getter for StoreId.
117+
*
118+
* @return int|null
119+
*/
120+
public function getStoreId(): ?int;
121+
122+
/**
123+
* Setter for StoreId.
124+
*
125+
* @param int|null $storeId
126+
*
127+
* @return void
128+
*/
129+
public function setStoreId(?int $storeId): void;
130+
}

Block/Form/AsyncEvent/Back.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace MageOS\AsyncEventsAdminUi\Block\Form\AsyncEvent;
5+
6+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
7+
8+
/**
9+
* Back to list button.
10+
*/
11+
class Back extends GenericButton implements ButtonProviderInterface
12+
{
13+
/**
14+
* Retrieve Back To Grid button settings.
15+
*
16+
* @return array
17+
*/
18+
public function getButtonData(): array
19+
{
20+
return $this->wrapButtonSettings(
21+
__('Back To Grid')->getText(),
22+
'back',
23+
sprintf("location.href = '%s';", $this->getUrl('*/*/')),
24+
[],
25+
10
26+
);
27+
}
28+
}

Block/Form/AsyncEvent/Delete.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace MageOS\AsyncEventsAdminUi\Block\Form\AsyncEvent;
5+
6+
use MageOS\AsyncEventsAdminUi\Api\Data\AsyncEventInterface;
7+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
8+
9+
/**
10+
* Delete entity button.
11+
*/
12+
class Delete extends GenericButton implements ButtonProviderInterface
13+
{
14+
/**
15+
* Retrieve Delete button settings.
16+
*
17+
* @return array
18+
*/
19+
public function getButtonData(): array
20+
{
21+
if (!$this->getSubscriptionId()) {
22+
return [];
23+
}
24+
25+
return $this->wrapButtonSettings(
26+
__('Delete')->getText(),
27+
'delete',
28+
sprintf("deleteConfirm('%s', '%s')",
29+
__('Are you sure you want to delete this asyncevent?'),
30+
$this->getUrl(
31+
'*/*/delete',
32+
[AsyncEventInterface::SUBSCRIPTION_ID => $this->getSubscriptionId()]
33+
)
34+
),
35+
[],
36+
20
37+
);
38+
}
39+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace MageOS\AsyncEventsAdminUi\Block\Form\AsyncEvent;
5+
6+
use MageOS\AsyncEventsAdminUi\Api\Data\AsyncEventInterface;
7+
use Magento\Backend\Block\Widget\Context;
8+
use Magento\Framework\UrlInterface;
9+
10+
/**
11+
* Generic (form) button for AsyncEvent entity.
12+
*/
13+
class GenericButton
14+
{
15+
/**
16+
* @var Context
17+
*/
18+
private Context $context;
19+
20+
/**
21+
* @var UrlInterface
22+
*/
23+
private UrlInterface $urlBuilder;
24+
25+
/**
26+
* @param Context $context
27+
*/
28+
public function __construct(
29+
Context $context
30+
)
31+
{
32+
$this->context = $context;
33+
$this->urlBuilder = $context->getUrlBuilder();
34+
}
35+
36+
/**
37+
* Get AsyncEvent entity id.
38+
*
39+
* @return int
40+
*/
41+
public function getSubscriptionId(): int
42+
{
43+
return (int)$this->context->getRequest()->getParam(AsyncEventInterface::SUBSCRIPTION_ID);
44+
}
45+
46+
/**
47+
* Wrap button specific options to settings array.
48+
*
49+
* @param string $label
50+
* @param string $class
51+
* @param string $onclick
52+
* @param array $dataAttribute
53+
* @param int $sortOrder
54+
*
55+
* @return array
56+
*/
57+
protected function wrapButtonSettings(
58+
string $label,
59+
string $class,
60+
string $onclick = '',
61+
array $dataAttribute = [],
62+
int $sortOrder = 0
63+
): array
64+
{
65+
return [
66+
'label' => $label,
67+
'on_click' => $onclick,
68+
'data_attribute' => $dataAttribute,
69+
'class' => $class,
70+
'sort_order' => $sortOrder
71+
];
72+
}
73+
74+
/**
75+
* Get url.
76+
*
77+
* @param string $route
78+
* @param array $params
79+
*
80+
* @return string
81+
*/
82+
protected function getUrl(string $route, array $params = []): string
83+
{
84+
return $this->urlBuilder->getUrl($route, $params);
85+
}
86+
}

Block/Form/AsyncEvent/Save.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace MageOS\AsyncEventsAdminUi\Block\Form\AsyncEvent;
5+
6+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
7+
8+
/**
9+
* Save entity button.
10+
*/
11+
class Save extends GenericButton implements ButtonProviderInterface
12+
{
13+
/**
14+
* Retrieve Save button settings.
15+
*
16+
* @return array
17+
*/
18+
public function getButtonData(): array
19+
{
20+
return $this->wrapButtonSettings(
21+
__('Save')->getText(),
22+
'save primary',
23+
'',
24+
[
25+
'mage-init' => ['button' => ['event' => 'save']],
26+
'form-role' => 'save'
27+
],
28+
30
29+
);
30+
}
31+
}

0 commit comments

Comments
 (0)