[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/api/components/com_privacy/src/Controller/ -> RequestsController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.API
   5   * @subpackage  com_privacy
   6   *
   7   * @copyright   (C) 2019 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\Privacy\Api\Controller;
  12  
  13  use Joomla\CMS\MVC\Controller\ApiController;
  14  use Joomla\Component\Privacy\Api\View\Requests\JsonapiView;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * The requests controller
  22   *
  23   * @since  4.0.0
  24   */
  25  class RequestsController extends ApiController
  26  {
  27      /**
  28       * The content type of the item.
  29       *
  30       * @var    string
  31       * @since  4.0.0
  32       */
  33      protected $contentType = 'requests';
  34  
  35      /**
  36       * The default view for the display method.
  37       *
  38       * @var    string
  39       * @since  3.0
  40       */
  41      protected $default_view = 'requests';
  42  
  43      /**
  44       * Export request data
  45       *
  46       * @param   integer  $id  The primary key to display. Leave empty if you want to retrieve data from the request
  47       *
  48       * @return  static  A \JControllerLegacy object to support chaining.
  49       *
  50       * @since   4.0.0
  51       */
  52      public function export($id = null)
  53      {
  54          if ($id === null) {
  55              $id = $this->input->get('id', 0, 'int');
  56          }
  57  
  58          $viewType   = $this->app->getDocument()->getType();
  59          $viewName   = $this->input->get('view', $this->default_view);
  60          $viewLayout = $this->input->get('layout', 'default', 'string');
  61  
  62          try {
  63              /** @var JsonapiView $view */
  64              $view = $this->getView(
  65                  $viewName,
  66                  $viewType,
  67                  '',
  68                  ['base_path' => $this->basePath, 'layout' => $viewLayout, 'contentType' => $this->contentType]
  69              );
  70          } catch (\Exception $e) {
  71              throw new \RuntimeException($e->getMessage());
  72          }
  73  
  74          $model = $this->getModel('export');
  75  
  76          try {
  77              $modelName = $model->getName();
  78          } catch (\Exception $e) {
  79              throw new \RuntimeException($e->getMessage());
  80          }
  81  
  82          $model->setState($modelName . '.request_id', $id);
  83  
  84          $view->setModel($model, true);
  85  
  86          $view->document = $this->app->getDocument();
  87          $view->export();
  88  
  89          return $this;
  90      }
  91  }


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