Skip to content

Commit

Permalink
Virtual Theme Check: Start
Browse files Browse the repository at this point in the history
  • Loading branch information
rommmka committed Dec 28, 2022
1 parent 2e8a7e7 commit 53f1158
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Block/Adminhtml/Config/Form/Field/VirtualCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Swissup\Core\Block\Adminhtml\Config\Form\Field;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Theme\Model\ResourceModel\Theme\Collection;

class VirtualCheck extends \Magento\Config\Block\System\Config\Form\Field
{

protected $_template = 'config/field/virtual_check.phtml';

public function render(AbstractElement $element)
{
$this->assign('configElement', $element);
$html = $this->toHtml();
return $this->_decorateRowHtml($element, "<td class='themes-table' colspan=\"3\">$html</td>");
}

public function getVirtualThemes()
{
return ObjectManager::getInstance()->create(Collection::class)
->addFieldToFilter('type', 1);

}
}
18 changes: 18 additions & 0 deletions Model/ResourceModel/VirtualCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Swissup\Core\Model\ResourceModel;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class VirtualCheck extends AbstractDb
{
/**
* Model initialization
*
* @return void
*/
protected function _construct()
{
$this->_init('theme', 'theme_title');
}
}
26 changes: 26 additions & 0 deletions Model/ResourceModel/VirtualCheck/Collection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Swissup\Core\Model\ResourceModel\VirtualCheck;

use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;

class Collection extends AbstractCollection
{
/**
* @var string
*/
protected $_idFieldName = 'theme_id';

/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init(
\Swissup\Core\Model\VirtualCheck::class,
\Swissup\Core\Model\ResourceModel\VirtualCheck::class
);
}
}
9 changes: 9 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>

<group id="troubleshooting" translate="label" type="text" sortOrder="260" showInDefault="1">
<label>Troubleshooting</label>
<field id="virtualcheck" translate="label" type="textarea" sortOrder="260" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Preview</label>
<frontend_model>Swissup\Core\Block\Adminhtml\Config\Form\Field\VirtualCheck</frontend_model>
</field>
</group>

</section>
</system>
</config>
38 changes: 38 additions & 0 deletions view/adminhtml/templates/config/field/virtual_check.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<style>
#row_swissup_core_troubleshooting_virtualcheck .themes-table h4 {padding-left: 0}
#row_swissup_core_troubleshooting_virtualcheck .themes-table table {max-width: 500px}
#row_swissup_core_troubleshooting_virtualcheck .themes-table td { text-align-last: left; }
#row_swissup_core_troubleshooting_virtualcheck .themes-table th { text-align-last: left; }

#row_swissup_core_troubleshooting_virtualcheck .themes-table td.virtual::before {
display:inline-block;
content: '';
width: 15px;
height: 15px;
background-color: red;
border-radius: 50%;
margin-right: 10px;
vertical-align: middle;
}

</style>



<h4>Virtual Theme Check</h4>

<?php
if ($block->getVirtualThemes()): ?>
<p style="color: green;">No virtual themes found. Check: passed!</p>
<?php else: ?>
<table>
<tbody>
<?php foreach ($block->getVirtualThemes() as $theme): ?>
<tr>
<td scope="row"><?php echo $theme->getThemeTitle(); ?></th>
<td class="virtual">Virtual</th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

0 comments on commit 53f1158

Please sign in to comment.