Skip to content

Commit 69be4d3

Browse files
committed
commit
1 parent 0bb4dab commit 69be4d3

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

app/site/controllers/Admin/Commerce/Books.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use App\Site\Models\Book;
2222
use Phpfastcache\Exceptions\PhpfastcacheSimpleCacheException;
2323
use App\Base\Models\TaxClass;
24+
use App\Site\Models\MediaElement as Media;
2425

2526
/**
2627
* "Books" Admin Page
@@ -87,13 +88,15 @@ public function getFormDefinition(FAPI\Form $form, array &$form_state): FAPI\For
8788

8889
switch ($type) {
8990
case 'edit':
90-
$this->addActionLink(
91-
'media-btn',
92-
'media-btn',
93-
$this->getHtmlRenderer()->getIcon('image') . ' ' . $this->getUtils()->translate('Media', locale: $this->getCurrentLocale()),
94-
$this->getUrl('crud.app.site.controllers.admin.json.bookmedia', ['id' => $this->getRequest()->query->get('product_id')]) . '?product_id=' . $this->getRequest()->query->get('product_id') . '&product_type=book&action=new',
95-
'btn btn-sm btn-light inToolSidePanel'
96-
);
91+
if (Media::getCollection()->count() > 0) {
92+
$this->addActionLink(
93+
'media-btn',
94+
'media-btn',
95+
$this->getHtmlRenderer()->getIcon('image') . ' ' . $this->getUtils()->translate('Media', locale: $this->getCurrentLocale()),
96+
$this->getUrl('crud.app.site.controllers.admin.json.bookmedia', ['id' => $this->getRequest()->query->get('product_id')]) . '?product_id=' . $this->getRequest()->query->get('product_id') . '&product_type=book&action=new',
97+
'btn btn-sm btn-light inToolSidePanel'
98+
);
99+
}
97100

98101
// intentional fall trough
99102
// no break

app/site/controllers/Admin/Commerce/DownloadableProducts.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ public function getFormDefinition(FAPI\Form $form, array &$form_state): FAPI\For
8989

9090
switch ($type) {
9191
case 'edit':
92-
$this->addActionLink(
93-
'media-btn',
94-
'media-btn',
95-
$this->getHtmlRenderer()->getIcon('image') . ' ' . $this->getUtils()->translate('Media', locale: $this->getCurrentLocale()),
96-
$this->getUrl('crud.app.site.controllers.admin.json.downloadablemedia', ['id' => $this->getRequest()->query->get('product_id')]) . '?product_id=' . $this->getRequest()->query->get('product_id') . '&product_type=downloadable&action=new',
97-
'btn btn-sm btn-light inToolSidePanel'
98-
);
92+
if (Media::getCollection()->count() > 0) {
93+
$this->addActionLink(
94+
'media-btn',
95+
'media-btn',
96+
$this->getHtmlRenderer()->getIcon('image') . ' ' . $this->getUtils()->translate('Media', locale: $this->getCurrentLocale()),
97+
$this->getUrl('crud.app.site.controllers.admin.json.downloadablemedia', ['id' => $this->getRequest()->query->get('product_id')]) . '?product_id=' . $this->getRequest()->query->get('product_id') . '&product_type=downloadable&action=new',
98+
'btn btn-sm btn-light inToolSidePanel'
99+
);
100+
}
99101

100102
// intentional fall trough
101103
// no break

0 commit comments

Comments
 (0)