File tree Expand file tree Collapse file tree 10 files changed +337
-1
lines changed Expand file tree Collapse file tree 10 files changed +337
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class BackButton
13
+ */
14
+ class BackButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ return [
22
+ 'label ' => __ ('Back ' ),
23
+ 'on_click ' => sprintf ("location.href = '%s'; " , $ this ->getBackUrl ()),
24
+ 'class ' => 'back ' ,
25
+ 'sort_order ' => 10
26
+ ];
27
+ }
28
+
29
+ /**
30
+ * Get URL for back (reset) button
31
+ *
32
+ * @return string
33
+ */
34
+ public function getBackUrl ()
35
+ {
36
+ return $ this ->getUrl ('*/*/ ' );
37
+ }
38
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Button "Create"
13
+ */
14
+ class CreateButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ return [
22
+ 'label ' => __ ('Create ' ),
23
+ 'class ' => 'save primary ' ,
24
+ 'data_attribute ' => [
25
+ 'mage-init ' => ['button ' => ['event ' => 'save ' ]],
26
+ 'form-role ' => 'save ' ,
27
+ ],
28
+ 'sort_order ' => 10
29
+ ];
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class DeleteButton
13
+ */
14
+ class DeleteButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+
17
+ /**
18
+ * @return array
19
+ */
20
+ public function getButtonData ()
21
+ {
22
+ $ data = [];
23
+ if ($ this ->getObjectId ()) {
24
+ $ data = [
25
+ 'label ' => __ ('Delete ' ),
26
+ 'class ' => 'delete ' ,
27
+ 'on_click ' => 'deleteConfirm( \'' . __ (
28
+ 'Are you sure you want to do this? '
29
+ ) . '\', \'' . $ this ->getDeleteUrl () . '\') ' ,
30
+ 'sort_order ' => 20 ,
31
+ ];
32
+ }
33
+ return $ data ;
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getDeleteUrl ()
40
+ {
41
+ return $ this ->getUrl ('*/*/delete ' , ['id ' => $ this ->getObjectId ()]);
42
+ }
43
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class DuplicateButton
13
+ */
14
+ class DuplicateButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ $ data = [];
22
+ if ($ this ->getObjectId ()) {
23
+ $ data = [
24
+ 'label ' => __ ('Duplicate ' ),
25
+ 'class ' => 'duplicate ' ,
26
+ 'on_click ' => 'window.location= \'' . $ this ->getDuplicateUrl () . '\'' ,
27
+ 'sort_order ' => 40 ,
28
+ ];
29
+ }
30
+ return $ data ;
31
+ }
32
+
33
+ /**
34
+ * @return string
35
+ */
36
+ public function getDuplicateUrl ()
37
+ {
38
+ return $ this ->getUrl ('*/*/duplicate ' , ['id ' => $ this ->getObjectId ()]);
39
+ }
40
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Backend \Block \Widget \Context ;
10
+ use Magento \Framework \Exception \NoSuchEntityException ;
11
+
12
+ /**
13
+ * Class GenericButton
14
+ */
15
+ class GenericButton
16
+ {
17
+ /**
18
+ * @var Context
19
+ */
20
+ protected $ context ;
21
+
22
+ /**
23
+ * @param Context $context
24
+ * @param BlockRepositoryInterface $blockRepository
25
+ */
26
+ public function __construct (
27
+ Context $ context
28
+ ) {
29
+ $ this ->context = $ context ;
30
+ }
31
+
32
+ /**
33
+ * Return CMS block ID
34
+ *
35
+ * @return int|null
36
+ */
37
+ public function getObjectId ()
38
+ {
39
+ return $ this ->context ->getRequest ()->getParam ('id ' );
40
+ }
41
+
42
+ /**
43
+ * Generate url by route and parameters
44
+ *
45
+ * @param string $route
46
+ * @param array $params
47
+ * @return string
48
+ */
49
+ public function getUrl ($ route = '' , $ params = [])
50
+ {
51
+ return $ this ->context ->getUrlBuilder ()->getUrl ($ route , $ params );
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class PreviewButton
13
+ */
14
+ class PreviewButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ $ data = [];
22
+ if ($ this ->getObjectId ()) {
23
+ $ data = [
24
+ 'label ' => __ ('Preview ' ),
25
+ 'class ' => 'preview ' ,
26
+ 'on_click ' => 'window.open( \'' . $ this ->getPreviewUrl () . '\'); ' ,
27
+ 'sort_order ' => 35 ,
28
+ ];
29
+ }
30
+ return $ data ;
31
+ }
32
+
33
+ /**
34
+ * @return string
35
+ */
36
+ public function getPreviewUrl ()
37
+ {
38
+ return $ this ->getUrl ('*/*/preview ' , ['id ' => $ this ->getObjectId ()]);
39
+ }
40
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class ResetButton
13
+ */
14
+ class ResetButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ return [
22
+ 'label ' => __ ('Reset ' ),
23
+ 'class ' => 'reset ' ,
24
+ 'on_click ' => 'location.reload(); ' ,
25
+ 'sort_order ' => 30
26
+ ];
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class SaveAndContinueButton
13
+ */
14
+ class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+
17
+ /**
18
+ * @return array
19
+ */
20
+ public function getButtonData ()
21
+ {
22
+ return [
23
+ 'label ' => __ ('Save and Continue Edit ' ),
24
+ 'class ' => 'save ' ,
25
+ 'data_attribute ' => [
26
+ 'mage-init ' => [
27
+ 'button ' => ['event ' => 'saveAndContinueEdit ' ],
28
+ ],
29
+ ],
30
+ 'sort_order ' => 80 ,
31
+ ];
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magefan (support@magefan.com). All rights reserved.
4
+ * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5
+ */
6
+
7
+ namespace Magefan \Community \Block \Adminhtml \Edit ;
8
+
9
+ use Magento \Framework \View \Element \UiComponent \Control \ButtonProviderInterface ;
10
+
11
+ /**
12
+ * Class SaveButton
13
+ */
14
+ class SaveButton extends GenericButton implements ButtonProviderInterface
15
+ {
16
+ /**
17
+ * @return array
18
+ */
19
+ public function getButtonData ()
20
+ {
21
+ return [
22
+ 'label ' => __ ('Save ' ),
23
+ 'class ' => 'save primary ' ,
24
+ 'data_attribute ' => [
25
+ 'mage-init ' => ['button ' => ['event ' => 'save ' ]],
26
+ 'form-role ' => 'save ' ,
27
+ ],
28
+ 'sort_order ' => 90 ,
29
+ ];
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -83,7 +83,6 @@ abstract class Actions extends \Magento\Backend\App\Action
83
83
84
84
/**
85
85
* @param Action\Context $context
86
- * @param PostDataProcessor $dataProcessor
87
86
* @param DataPersistorInterface $dataPersistor
88
87
*/
89
88
public function __construct (
You can’t perform that action at this time.
0 commit comments