[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_workflow/src/Table/ -> TransitionTable.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\Table;
  12  
  13  use Joomla\CMS\Access\Rules;
  14  use Joomla\CMS\Table\Table;
  15  use Joomla\Database\DatabaseDriver;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Transition table
  23   *
  24   * @since  4.0.0
  25   */
  26  class TransitionTable extends Table
  27  {
  28      /**
  29       * Indicates that columns fully support the NULL value in the database
  30       *
  31       * @var    boolean
  32       *
  33       * @since  4.0.0
  34       */
  35      protected $_supportNullValue = true;
  36  
  37      /**
  38       * An array of key names to be json encoded in the bind function
  39       *
  40       * @var    array
  41       *
  42       * @since  4.0.0
  43       */
  44      protected $_jsonEncode = [
  45          'options'
  46      ];
  47  
  48      /**
  49       * @param   DatabaseDriver  $db  Database connector object
  50       *
  51       * @since  4.0.0
  52       */
  53      public function __construct(DatabaseDriver $db)
  54      {
  55          parent::__construct('#__workflow_transitions', 'id', $db);
  56      }
  57  
  58      /**
  59       * Method to bind an associative array or object to the Table instance.
  60       * This method only binds properties that are publicly accessible and optionally
  61       * takes an array of properties to ignore when binding.
  62       *
  63       * @param   array|object  $src     An associative array or object to bind to the Table instance.
  64       * @param   array|string  $ignore  An optional array or space separated list of properties to ignore while binding.
  65       *
  66       * @return  boolean  True on success.
  67       *
  68       * @since   4.0.0
  69       * @throws  \InvalidArgumentException
  70       */
  71      public function bind($src, $ignore = array())
  72      {
  73          // Bind the rules.
  74          if (isset($src['rules']) && \is_array($src['rules'])) {
  75              $rules = new Rules($src['rules']);
  76              $this->setRules($rules);
  77          }
  78  
  79          return parent::bind($src, $ignore);
  80      }
  81  
  82      /**
  83       * Method to compute the default name of the asset.
  84       * The default name is in the form table_name.id
  85       * where id is the value of the primary key of the table.
  86       *
  87       * @return  string
  88       *
  89       * @since  4.0.0
  90       */
  91      protected function _getAssetName()
  92      {
  93          $k = $this->_tbl_key;
  94          $workflow = new WorkflowTable($this->getDbo());
  95          $workflow->load($this->workflow_id);
  96  
  97          $parts = explode('.', $workflow->extension);
  98  
  99          $extension = array_shift($parts);
 100  
 101          return $extension . '.transition.' . (int) $this->$k;
 102      }
 103  
 104      /**
 105       * Method to return the title to use for the asset table.
 106       *
 107       * @return  string
 108       *
 109       * @since  4.0.0
 110       */
 111      protected function _getAssetTitle()
 112      {
 113          return $this->title;
 114      }
 115  
 116      /**
 117       * Get the parent asset id for the record
 118       *
 119       * @param   Table    $table  A Table object for the asset parent.
 120       * @param   integer  $id     The id for the asset
 121       *
 122       * @return  integer  The id of the asset's parent
 123       *
 124       * @since  4.0.0
 125       */
 126      protected function _getAssetParentId(Table $table = null, $id = null)
 127      {
 128          $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
 129  
 130          $workflow = new WorkflowTable($this->getDbo());
 131          $workflow->load($this->workflow_id);
 132  
 133          $parts = explode('.', $workflow->extension);
 134  
 135          $extension = array_shift($parts);
 136  
 137          $name = $extension . '.workflow.' . (int) $workflow->id;
 138  
 139          $asset->loadByName($name);
 140          $assetId = $asset->id;
 141  
 142          return !empty($assetId) ? $assetId : parent::_getAssetParentId($table, $id);
 143      }
 144  }


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