forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
130 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Joomla\CMS\Workflow; | ||
|
||
\defined('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\CMS\Form\Form; | ||
use function method_exists; | ||
|
||
/** | ||
* Trait for component workflow plugins. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
trait WorkflowPluginTrait { | ||
|
||
/** | ||
* Add different parameter options to the transition view, we need when executing the transition | ||
* | ||
* @param Form $form The form | ||
* @param \stdClass $data The data | ||
* | ||
* @return boolean | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
protected function enhanceWorkflowTransitionForm(Form $form, $data) { | ||
|
||
$workflow = $this->getWorkflow((int) ($data->workflow_id ?? $form->getValue('workflow_id'))); | ||
|
||
if (empty($workflow->id) || !$this->isSupported($workflow->extension)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (file_exists(__DIR__ . '/forms/action.xml')) | ||
{ | ||
$form->loadFile(__DIR__ . '/forms/action.xml'); | ||
} | ||
|
||
return $workflow; | ||
} | ||
|
||
protected function getWorkflow(int $workflow_id = null) { | ||
|
||
$workflow_id = $workflow_id ?? $this->app->input->getInt('workflow_id'); | ||
|
||
if (is_array($workflow_id)) { | ||
return false; | ||
} | ||
|
||
return $this->app->bootComponent('com_workflow') | ||
->getMVCFactory() | ||
->createModel('Workflow', 'Administrator', ['ignore_request' => true]) | ||
->getItem($workflow_id); | ||
} | ||
|
||
|
||
/** | ||
* Check if the current plugin should execute workflow related activities | ||
* | ||
* @param string $context | ||
* @return boolean | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function isSupported($context) | ||
{ | ||
return false; | ||
} | ||
} |
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