Skip to content

Commit 1ca8e8c

Browse files
author
flurrybox
committed
Initial commit
0 parents  commit 1ca8e8c

19 files changed

+1103
-0
lines changed

Block/Adminhtml/ExtensionList.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* This file is part of the Flurrybox Core package.
4+
*
5+
* DISCLAIMER
6+
*
7+
* Do not edit or add to this file if you wish to upgrade Flurrybox Core
8+
* to newer versions in the future.
9+
*
10+
* @copyright Copyright (c) 2018 Flurrybox, Ltd. (https://flurrybox.com/)
11+
* @license GNU General Public License ("GPL") v3.0
12+
*
13+
* For the full copyright and license information, please view the LICENSE
14+
* file that was distributed with this source code.
15+
*/
16+
17+
declare(strict_types=1);
18+
19+
namespace Flurrybox\Core\Block\Adminhtml;
20+
21+
use Flurrybox\Core\Model\ExtensionMetaDataInterface;
22+
use Flurrybox\Core\Model\Extensions;
23+
use Magento\Backend\Block\Template\Context;
24+
use Magento\Config\Block\System\Config\Form\Field;
25+
use Magento\Framework\Data\Form\Element\AbstractElement;
26+
27+
/**
28+
* Installed extension list.
29+
*/
30+
class ExtensionList extends Field
31+
{
32+
/**
33+
* @var string
34+
*/
35+
protected $_template = 'Flurrybox_Core::list.phtml';
36+
37+
/**
38+
* @var Extensions
39+
*/
40+
protected $extensions;
41+
42+
/**
43+
* ExtensionList constructor.
44+
*
45+
* @param Context $context
46+
* @param Extensions $extensions
47+
* @param array $data
48+
*/
49+
public function __construct(
50+
Context $context,
51+
Extensions $extensions,
52+
array $data = []
53+
) {
54+
parent::__construct($context, $data);
55+
56+
$this->extensions = $extensions;
57+
}
58+
59+
/**
60+
* Render field as a custom block.
61+
*
62+
* @param AbstractElement $element
63+
*
64+
* @return string
65+
* @throws \Magento\Framework\Exception\ValidatorException
66+
*/
67+
public function render(AbstractElement $element)
68+
{
69+
return $this->_decorateRowHtml($element, $this->fetchView($this->getTemplateFile()));
70+
}
71+
72+
/**
73+
* Get extension list.
74+
*
75+
* @return ExtensionMetaDataInterface[]
76+
*/
77+
public function getExtensions()
78+
{
79+
return $this->extensions->getExtensions();
80+
}
81+
82+
/**
83+
* Get latest extension version.
84+
*
85+
* @param ExtensionMetaDataInterface $extension
86+
*
87+
* @return string
88+
*/
89+
public function getLatestVersion(ExtensionMetaDataInterface $extension)
90+
{
91+
return $this->extensions->getLatestVersion($extension);
92+
}
93+
94+
/**
95+
* Check if module is outdated.
96+
*
97+
* @param ExtensionMetaDataInterface $extension
98+
*
99+
* @return string
100+
*/
101+
public function isOutdated(ExtensionMetaDataInterface $extension)
102+
{
103+
return !$this->extensions->isLatestVersion($extension) ? 'outdated' : '';
104+
}
105+
}

Model/ExtensionMetaData.php

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
/**
3+
* This file is part of the Flurrybox Core package.
4+
*
5+
* DISCLAIMER
6+
*
7+
* Do not edit or add to this file if you wish to upgrade Flurrybox Core
8+
* to newer versions in the future.
9+
*
10+
* @copyright Copyright (c) 2018 Flurrybox, Ltd. (https://flurrybox.com/)
11+
* @license GNU General Public License ("GPL") v3.0
12+
*
13+
* For the full copyright and license information, please view the LICENSE
14+
* file that was distributed with this source code.
15+
*/
16+
17+
declare(strict_types=1);
18+
19+
namespace Flurrybox\Core\Model;
20+
21+
/**
22+
* Extension entity.
23+
*/
24+
class ExtensionMetaData implements ExtensionMetaDataInterface
25+
{
26+
/**
27+
* @var string
28+
*/
29+
protected $name;
30+
31+
/**
32+
* @var string
33+
*/
34+
protected $description;
35+
36+
/**
37+
* @var string
38+
*/
39+
protected $identificationCode;
40+
41+
/**
42+
* @var string
43+
*/
44+
protected $version;
45+
46+
/**
47+
* @var string|null
48+
*/
49+
protected $storePage;
50+
51+
/**
52+
* @var string|null
53+
*/
54+
protected $helpPage;
55+
56+
/**
57+
* ExtensionMetaData constructor.
58+
*
59+
* @param string $name
60+
* @param string $description
61+
* @param string $identificationCode
62+
* @param string $version
63+
* @param string|null $storePage
64+
* @param string|null $helpPage
65+
*/
66+
public function __construct(
67+
$name,
68+
$description,
69+
$identificationCode,
70+
$version,
71+
$storePage = null,
72+
$helpPage = null
73+
) {
74+
$this->name = $name;
75+
$this->description = $description;
76+
$this->identificationCode = $identificationCode;
77+
$this->version = $version;
78+
$this->storePage = $storePage;
79+
$this->helpPage = $helpPage;
80+
}
81+
82+
/**
83+
* Get extension name.
84+
*
85+
* @return string
86+
*/
87+
public function getName()
88+
{
89+
return $this->name;
90+
}
91+
92+
/**
93+
* Get extension identification code.
94+
*
95+
* @return string
96+
*/
97+
public function getIdentificationCode()
98+
{
99+
return $this->identificationCode;
100+
}
101+
102+
/**
103+
* Get extension version.
104+
*
105+
* @return string
106+
*/
107+
public function getVersion()
108+
{
109+
return $this->version;
110+
}
111+
112+
/**
113+
* Get extension description.
114+
*
115+
* @return string
116+
*/
117+
public function getDescription()
118+
{
119+
return $this->description;
120+
}
121+
122+
/**
123+
* Get store page url.
124+
*
125+
* @return string
126+
*/
127+
public function getStorePageUrl()
128+
{
129+
return $this->storePage;
130+
}
131+
132+
/**
133+
* Get installation and usage guide url.
134+
*
135+
* @return string
136+
*/
137+
public function getHelpUrl()
138+
{
139+
return $this->helpPage;
140+
}
141+
}

Model/ExtensionMetaDataInterface.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* This file is part of the Flurrybox Core package.
4+
*
5+
* DISCLAIMER
6+
*
7+
* Do not edit or add to this file if you wish to upgrade Flurrybox Core
8+
* to newer versions in the future.
9+
*
10+
* @copyright Copyright (c) 2018 Flurrybox, Ltd. (https://flurrybox.com/)
11+
* @license GNU General Public License ("GPL") v3.0
12+
*
13+
* For the full copyright and license information, please view the LICENSE
14+
* file that was distributed with this source code.
15+
*/
16+
17+
namespace Flurrybox\Core\Model;
18+
19+
/**
20+
* Extension entity.
21+
*/
22+
interface ExtensionMetaDataInterface
23+
{
24+
/**
25+
* Get extension name.
26+
*
27+
* @return string
28+
*/
29+
public function getName();
30+
31+
/**
32+
* Get extension identification code.
33+
*
34+
* @return string
35+
*/
36+
public function getIdentificationCode();
37+
38+
/**
39+
* Get extension version.
40+
*
41+
* @return string
42+
*/
43+
public function getVersion();
44+
45+
/**
46+
* Get extension description.
47+
*
48+
* @return string
49+
*/
50+
public function getDescription();
51+
52+
/**
53+
* Get store page url.
54+
*
55+
* @return string
56+
*/
57+
public function getStorePageUrl();
58+
59+
/**
60+
* Get installation and usage guide url.
61+
*
62+
* @return string
63+
*/
64+
public function getHelpUrl();
65+
}

0 commit comments

Comments
 (0)