Skip to content

Commit fae8b9b

Browse files
authored
[4.0] Exclude tab workflow if workflow is not enabled (#31374)
1 parent f69a9b0 commit fae8b9b

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

administrator/components/com_categories/tmpl/category/edit.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Joomla\CMS\Language\Text;
1616
use Joomla\CMS\Layout\LayoutHelper;
1717
use Joomla\CMS\Router\Route;
18+
use Joomla\CMS\Workflow\WorkflowServiceInterface;
1819

1920
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
2021
$wa = $this->document->getWebAssetManager();
@@ -30,6 +31,17 @@
3031

3132
// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
3233
$this->ignore_fieldsets = ['jmetadata', 'item_associations'];
34+
35+
$c = Factory::getApplication()->bootComponent($this->state->get('category.extension'));
36+
37+
$wcontext = $c->getCategoryWorkflowContext($this->state->get('category.section'));
38+
39+
if (!$c instanceof WorkflowServiceInterface
40+
|| !$c->isWorkflowActive($wcontext))
41+
{
42+
$this->ignore_fieldsets[] = 'workflow';
43+
}
44+
3345
$this->useCoreUI = true;
3446

3547
// In case of modal

administrator/components/com_content/src/Extension/ContentComponent.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ public function getWorkflowContexts(): array
195195
return $contexts;
196196
}
197197

198+
/**
199+
* Returns the workflow context based on the given category section
200+
*
201+
* @param string $section The section
202+
*
203+
* @return string|null
204+
*
205+
* @since __DEPLOY_VERSION__
206+
*/
207+
public function getCategoryWorkflowContext(?string $section = null): string
208+
{
209+
$context = $this->getWorkflowContexts();
210+
211+
return array_key_first($context);
212+
}
213+
198214
/**
199215
* Returns the table for the count items functions for the given section.
200216
*

administrator/components/com_content/src/Helper/ContentHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Joomla\CMS\Form\Form;
1616
use Joomla\CMS\Language\Text;
1717
use Joomla\CMS\Table\Category;
18+
use Joomla\CMS\Workflow\WorkflowServiceInterface;
1819
use Joomla\Database\ParameterType;
1920
use Joomla\Registry\Registry;
2021

@@ -97,6 +98,16 @@ public static function onPrepareForm(Form $form, $data)
9798

9899
$form->setFieldAttribute('workflow_id', 'default', 'inherit');
99100

101+
$component = Factory::getApplication()->bootComponent('com_content');
102+
103+
if (!$component instanceof WorkflowServiceInterface
104+
|| !$component->isWorkflowActive('com_content.article'))
105+
{
106+
$form->removeField('workflow_id', 'params');
107+
108+
return;
109+
}
110+
100111
$query = $db->getQuery(true);
101112

102113
$query->select($db->quoteName('title'))

libraries/src/Workflow/WorkflowServiceInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,15 @@ public function getWorkflowTableBySection(?string $section = null): string;
8989
* @since 4.0.0
9090
*/
9191
public function getWorkflowContexts(): array;
92+
93+
/**
94+
* Returns the workflow context based on the given category section
95+
*
96+
* @param string $section The section
97+
*
98+
* @return string|null
99+
*
100+
* @since __DEPLOY_VERSION__
101+
*/
102+
public function getCategoryWorkflowContext(?string $section = null): string;
92103
}

0 commit comments

Comments
 (0)