| Server IP : 104.21.84.107 / Your IP : 104.23.197.209 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/pregrados/ingenieria-agronomica/api/components/com_media/src/Model/ |
Upload File : |
<?php
/**
* @package Joomla.API
* @subpackage com_media
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Media\Api\Model;
use Joomla\CMS\MVC\Model\BaseModel;
use Joomla\CMS\MVC\Model\ListModelInterface;
use Joomla\CMS\Pagination\Pagination;
use Joomla\Component\Media\Administrator\Provider\ProviderManagerHelperTrait;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Media web service model supporting lists of media adapters.
*
* @since 4.1.0
*/
class AdaptersModel extends BaseModel implements ListModelInterface
{
use ProviderManagerHelperTrait;
/**
* A hacky way to enable the standard jsonapiView::displayList() to create a Pagination object,
* since com_media's ApiModel does not support pagination as we know from regular ListModel derived models.
*
* @var int
* @since 4.1.0
*/
private $total = 0;
/**
* Method to get a list of files and/or folders.
*
* @return array An array of data items.
*
* @since 4.1.0
*/
public function getItems(): array
{
$adapters = [];
foreach ($this->getProviderManager()->getProviders() as $provider) {
foreach ($provider->getAdapters() as $adapter) {
$obj = new \stdClass();
$obj->id = $provider->getID() . '-' . $adapter->getAdapterName();
$obj->provider_id = $provider->getID();
$obj->name = $adapter->getAdapterName();
$obj->path = $provider->getID() . '-' . $adapter->getAdapterName() . ':/';
$adapters[] = $obj;
}
}
// A hacky way to enable the standard jsonapiView::displayList() to create a Pagination object.
$this->total = \count($adapters);
return $adapters;
}
/**
* Method to get a \JPagination object for the data set.
*
* @return Pagination A Pagination object for the data set.
*
* @since 4.1.0
*/
public function getPagination(): Pagination
{
return new Pagination($this->getTotal(), $this->getStart(), 0);
}
/**
* Method to get the starting number of items for the data set. Because com_media's ApiModel
* does not support pagination as we know from regular ListModel derived models,
* we always start at the top.
*
* @return integer The starting number of items available in the data set.
*
* @since 4.1.0
*/
public function getStart(): int
{
return 0;
}
/**
* Method to get the total number of items for the data set.
*
* @return integer The total number of items available in the data set.
*
* @since 4.1.0
*/
public function getTotal(): int
{
return $this->total;
}
}