[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_workflow/src/Controller/ -> TransitionsController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_workflow
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Workflow\Administrator\Controller;
  12  
  13  use Joomla\CMS\Application\CMSApplication;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\Controller\AdminController;
  16  use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
  17  use Joomla\Input\Input;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Workflow Transitions controller
  25   *
  26   * @since  4.0.0
  27   */
  28  class TransitionsController extends AdminController
  29  {
  30      /**
  31       * The workflow where the transition takes place
  32       *
  33       * @var    integer
  34       * @since  4.0.0
  35       */
  36      protected $workflowId;
  37  
  38      /**
  39       * The extension
  40       *
  41       * @var    string
  42       * @since  4.0.0
  43       */
  44      protected $extension;
  45  
  46      /**
  47       * The section of the current extension
  48       *
  49       * @var    string
  50       * @since  4.0.0
  51       */
  52      protected $section;
  53  
  54      /**
  55       * The prefix to use with controller messages.
  56       *
  57       * @var    string
  58       * @since  4.0.0
  59       */
  60      protected $text_prefix = 'COM_WORKFLOW_TRANSITIONS';
  61  
  62      /**
  63       * Constructor.
  64       *
  65       * @param   array                $config   An optional associative array of configuration settings.
  66       * @param   MVCFactoryInterface  $factory  The factory.
  67       * @param   CMSApplication       $app      The Application for the dispatcher
  68       * @param   Input                $input    Input
  69       *
  70       * @since   4.0.0
  71       * @throws  \InvalidArgumentException when no extension or workflow id is set
  72       */
  73      public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
  74      {
  75          parent::__construct($config, $factory, $app, $input);
  76  
  77          // If workflow id is not set try to get it from input or throw an exception
  78          if (empty($this->workflowId)) {
  79              $this->workflowId = $this->input->getInt('workflow_id');
  80  
  81              if (empty($this->workflowId)) {
  82                  throw new \InvalidArgumentException(Text::_('COM_WORKFLOW_ERROR_WORKFLOW_ID_NOT_SET'));
  83              }
  84          }
  85  
  86          // If extension is not set try to get it from input or throw an exception
  87          if (empty($this->extension)) {
  88              $extension = $this->input->getCmd('extension');
  89  
  90              $parts = explode('.', $extension);
  91  
  92              $this->extension = array_shift($parts);
  93  
  94              if (!empty($parts)) {
  95                  $this->section = array_shift($parts);
  96              }
  97  
  98              if (empty($this->extension)) {
  99                  throw new \InvalidArgumentException(Text::_('COM_WORKFLOW_ERROR_EXTENSION_NOT_SET'));
 100              }
 101          }
 102      }
 103  
 104      /**
 105       * Proxy for getModel
 106       *
 107       * @param   string  $name    The model name. Optional.
 108       * @param   string  $prefix  The class prefix. Optional.
 109       * @param   array   $config  The array of possible config values. Optional.
 110       *
 111       * @return  \Joomla\CMS\MVC\Model\BaseDatabaseModel  The model.
 112       *
 113       * @since  4.0.0
 114       */
 115      public function getModel($name = 'Transition', $prefix = 'Administrator', $config = array('ignore_request' => true))
 116      {
 117          return parent::getModel($name, $prefix, $config);
 118      }
 119  
 120      /**
 121       * Gets the URL arguments to append to a list redirect.
 122       *
 123       * @return  string  The arguments to append to the redirect URL.
 124       *
 125       * @since   4.0.0
 126       */
 127      protected function getRedirectToListAppend()
 128      {
 129          $append = parent::getRedirectToListAppend();
 130  
 131          $append .= '&extension=' . $this->extension . ($this->section ? '.' . $this->section : '')
 132              . '&workflow_id=' . $this->workflowId;
 133  
 134          return $append;
 135      }
 136  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer