forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add context selector for workflow (joomla#104)
- Loading branch information
1 parent
35cb5be
commit 4ff9d23
Showing
6 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
administrator/components/com_workflow/forms/filter_workflows.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
administrator/components/com_workflow/src/Field/WorkflowcontextsField.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_workflow | ||
* | ||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\Component\Workflow\Administrator\Field; | ||
|
||
\defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Workflow\WorkflowServiceInterface; | ||
use Joomla\CMS\Form\Field\ListField; | ||
|
||
/** | ||
* Fields Contexts | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
class WorkflowcontextsField extends ListField | ||
{ | ||
/** | ||
* Type of the field | ||
* | ||
* @var string | ||
*/ | ||
public $type = 'Workflowcontexts'; | ||
|
||
/** | ||
* Method to get the field input markup for a generic list. | ||
* Use the multiple attribute to enable multiselect. | ||
* | ||
* @return string The field input markup. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function getInput() | ||
{ | ||
if (count($this->getOptions()) < 2) | ||
{ | ||
$this->layout = 'joomla.form.field.hidden'; | ||
} | ||
|
||
return parent::getInput(); | ||
} | ||
|
||
/** | ||
* Method to get the field options. | ||
* | ||
* @return array The field option objects. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function getOptions() | ||
{ | ||
$parts = explode('.', $this->value); | ||
|
||
$component = Factory::getApplication()->bootComponent($parts[0]); | ||
|
||
if ($component instanceof WorkflowServiceInterface) | ||
{ | ||
return $component->getWorkflowContexts(); | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters