Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codestyle fixes #73

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions administrator/components/com_content/src/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,26 +599,27 @@ public function getTransitions()
$query = $db->getQuery(true);

$query ->select(
[
$db->quoteName('t.id', 'value'),
$db->quoteName('t.title', 'text'),
$db->quoteName('t.from_stage_id'),
$db->quoteName('t.to_stage_id'),
$db->quoteName('s.id', 'stage_id'),
$db->quoteName('s.title', 'stage_title'),
$db->quoteName('t.workflow_id'),
]
)
->from($db->quoteName('#__workflow_transitions', 't'))
->innerJoin($db->quoteName('#__workflow_stages', 's'))
->where(
[
$db->quoteName('t.id', 'value'),
$db->quoteName('t.title', 'text'),
$db->quoteName('t.from_stage_id'),
$db->quoteName('t.to_stage_id'),
$db->quoteName('s.id', 'stage_id'),
$db->quoteName('s.title', 'stage_title'),
$db->quoteName('t.workflow_id'),
])
->from($db->quoteName('#__workflow_transitions', 't'))
->innerJoin($db->quoteName('#__workflow_stages', 's'))
->where(
[
$db->quoteName('t.to_stage_id') . ' = ' . $db->quoteName('s.id'),
$db->quoteName('t.published') . ' = 1',
$db->quoteName('s.published') . ' = 1',
]
)
->order($db->quoteName('t.ordering'))
->group($db->quoteName('t.id'));
$db->quoteName('t.to_stage_id') . ' = ' . $db->quoteName('s.id'),
$db->quoteName('t.published') . ' = 1',
$db->quoteName('s.published') . ' = 1',
]
)
->order($db->quoteName('t.ordering'))
->group($db->quoteName('t.id'));

$where = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ protected function addToolbar()
if (count($this->transitions))
{
$childBar->separatorButton('transition-headline')
->text('COM_CONTENT_RUN_TRANSITIONS')
->buttonClass('text-center py-2 h3');
->text('COM_CONTENT_RUN_TRANSITIONS')
->buttonClass('text-center py-2 h3');

$cmd = "Joomla.submitbutton('articles.runTransition');";
$messages = "{error: [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}";
Expand All @@ -181,10 +181,10 @@ protected function addToolbar()
foreach ($this->transitions as $transition)
{
$childBar->standardButton('transition')
->text($transition['text'])
->buttonClass('transition-' . (int) $transition['value'])
->icon('fas fa-project-diagram')
->onclick('document.adminForm.transition_id.value=' . (int) $transition['value'] . ';' . $cmd);
->text($transition['text'])
->buttonClass('transition-' . (int) $transition['value'])
->icon('fas fa-project-diagram')
->onclick('document.adminForm.transition_id.value=' . (int) $transition['value'] . ';' . $cmd);
}

$childBar->separatorButton('transition-separator');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function store($updateNulls = true)
{
if (!(int) $this->ordering)
{
$this->ordering = $this->getNextOrder($this->_db->quoteName('workflow_id') . ' = ' . (int) $this->workflow_id);
$this->ordering = $this->getNextOrder($this->_db->quoteName('workflow_id') . ' = ' . (int) $this->workflow_id);
}

$table = new StageTable($this->getDbo());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public function __construct(DatabaseDriver $db)
* @since 4.0.0
*/
public function store($updateNulls = true)
{
{
if (!(int) $this->ordering)
{
$this->ordering = $this->getNextOrder($this->_db->quoteName('workflow_id') . ' = ' . (int) $this->workflow_id);
$this->ordering = $this->getNextOrder($this->_db->quoteName('workflow_id') . ' = ' . (int) $this->workflow_id);
}

return parent::store($updateNulls);
Expand Down
14 changes: 13 additions & 1 deletion libraries/src/MVC/Model/WorkflowBehaviorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,27 @@
trait WorkflowBehaviorTrait
{
/**
* The for the component.
* The name of the component.
*
* @var string
* @since 4.0.0
*/
protected $extension = null;

/**
* The section of the component.
*
* @var string
* @since 4.0.0
*/
protected $section = '';

/**
* Is workflow for this component enabled?
*
* @var boolean
* @since 4.0.0
*/
protected $workflowEnabled = false;

/**
Expand Down
13 changes: 7 additions & 6 deletions libraries/src/Workflow/WorkflowServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*
* @since 4.0.0
*/
interface WorkflowServiceInterface {
interface WorkflowServiceInterface
{
/**
* Check if the functionality is supported by the context
*
* @param string $feature The functionality
* @param string $context The context of the functionality
* @param string $functionality The functionality
* @param string $context The context of the functionality
*
* @return bool
* @return boolean
*
* @since 4.0.0
*/
Expand All @@ -33,7 +34,7 @@ public function supportFunctionality($functionality, $context): bool;
*
* @param string $context The context of the workflow
*
* @return bool
* @return boolean
*/
public function getModelName($context): string;

Expand All @@ -42,7 +43,7 @@ public function getModelName($context): string;
*
* @param string $context The context of the workflow
*
* @return bool
* @return boolean
*/
public function isWorkflowActive($context): bool;

Expand Down
23 changes: 16 additions & 7 deletions libraries/src/Workflow/WorkflowServiceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\WorkflowModelInterface;

\defined('JPATH_PLATFORM') or die;
Expand All @@ -19,8 +20,16 @@
*
* @since 4.0.0
*/
trait WorkflowServiceTrait {
abstract function getMVCFactory();
trait WorkflowServiceTrait
{
/**
* Get a MVC factory
*
* @return MVCFactoryInterface
*
* @since __DEPLOY_VERSION__
*/
abstract public function getMVCFactory(): MVCFactoryInterface;

/** @var array Supported functionality */
protected $supportedFunctionality = [
Expand All @@ -31,10 +40,10 @@ abstract function getMVCFactory();
/**
* Check if the functionality is supported by the context
*
* @param string $feature The functionality
* @param string $context The context of the functionality
* @param string $functionality The functionality
* @param string $context The context of the functionality
*
* @return bool
* @return boolean
*/
public function supportFunctionality($functionality, $context): bool
{
Expand All @@ -56,7 +65,7 @@ public function supportFunctionality($functionality, $context): bool
*
* @param string $context The context of the workflow
*
* @return bool
* @return boolean
*/
public function getModelName($context) : string
{
Expand Down Expand Up @@ -91,7 +100,7 @@ public static function getConditions(string $extension): array
*
* @param string $context The context of the workflow
*
* @return bool
* @return boolean
*/
public function isWorkflowActive($context): bool
{
Expand Down
16 changes: 10 additions & 6 deletions plugins/workflow/publishing/publishing.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function onContentPrepareForm(Form $form, $data)
protected function enhanceTransitionForm(Form $form, $data)
{
$model = $this->app->bootComponent('com_workflow')
->getMVCFactory()->createModel('Workflow', 'Administrator', ['ignore_request' => true]);
->getMVCFactory()->createModel('Workflow', 'Administrator', ['ignore_request' => true]);

$workflow_id = !empty($data->workflow_id) ? (int) $data->workflow_id : (int) $form->getValue('workflow_id');

Expand Down Expand Up @@ -146,7 +146,7 @@ protected function enhanceItemForm(Form $form, $data)
$modelName = $component->getModelName($context);

$table = $component->getMVCFactory()->createModel($modelName, $this->app->getName(), ['ignore_request' => true])
->getTable();
->getTable();

$form->setFieldAttribute($table->getColumnAlias('published'), 'disabled', 'true');

Expand Down Expand Up @@ -227,9 +227,11 @@ public function onWorkflowBeforeTransition($context, $pks, $transition)

$value = (int) $transition->options->get('publishing');

// Here it becomes tricky. We would like to use the component models publish method, so we will
// Execute the normal "onContentBeforeChangeState" plugins. But they could cancel the execution,
// So we have to precheck and cancel the whole transition stuff if not allowed.
/**
* Here it becomes tricky. We would like to use the component models publish method, so we will
* Execute the normal "onContentBeforeChangeState" plugins. But they could cancel the execution,
* So we have to precheck and cancel the whole transition stuff if not allowed.
*/
$this->app->set('plgWorkflowPublishing.' . $context, $pks);

$result = $this->app->triggerEvent('onContentBeforeChangeState', [$context, $pks, $value]);
Expand Down Expand Up @@ -367,7 +369,9 @@ protected function isSupported($context)

$component = $this->app->bootComponent($parts[0]);

if (!$component instanceof WorkflowServiceInterface || !$component->isWorkflowActive($context) || !$component->supportFunctionality($this->supportname, $context))
if (!$component instanceof WorkflowServiceInterface
|| !$component->isWorkflowActive($context)
|| !$component->supportFunctionality($this->supportname, $context))
{
return false;
}
Expand Down