mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
_JEXEC & copyright
This commit is contained in:
parent
9a4ff028f4
commit
ffc26f48a8
@ -1,21 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Administrator
|
||||||
|
* @subpackage com_oauthserver
|
||||||
|
*
|
||||||
|
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||||
|
* @license MIT; see LICENSE.txt
|
||||||
|
**/
|
||||||
|
|
||||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Model;
|
namespace Webmasterskaya\Component\OauthServer\Administrator\Model;
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
use Joomla\CMS\Factory;
|
||||||
use Joomla\CMS\Form\Form;
|
use Joomla\CMS\Form\Form;
|
||||||
use Joomla\CMS\MVC\Model\AdminModel;
|
use Joomla\CMS\MVC\Model\AdminModel;
|
||||||
|
use Joomla\CMS\Table\Table;
|
||||||
|
use Webmasterskaya\Component\OauthServer\Administrator\Table\AccessTokenTable;
|
||||||
|
|
||||||
|
\defined('_JEXEC') or die;
|
||||||
|
|
||||||
class AccessTokenModel extends AdminModel implements RevokedModelInterface
|
class AccessTokenModel extends AdminModel implements RevokedModelInterface
|
||||||
{
|
{
|
||||||
use GetItemByIdentifierTrait;
|
use GetItemByIdentifierTrait;
|
||||||
use RevokedModelTrait;
|
use RevokedModelTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
* @since version
|
||||||
|
*/
|
||||||
public function getForm($data = [], $loadData = true): Form|bool
|
public function getForm($data = [], $loadData = true): Form|bool
|
||||||
{
|
{
|
||||||
$form = $this->loadForm('com_oauthserver.access_token', 'access_token', ['control' => 'jform', 'load_data' => $loadData]);
|
$form = $this->loadForm('com_oauthserver.access_token', 'access_token', ['control' => 'jform', 'load_data' => $loadData]);
|
||||||
|
|
||||||
if (empty($form)) {
|
if (empty($form))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,11 +39,7 @@ class AccessTokenModel extends AdminModel implements RevokedModelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to get the data that should be injected in the form.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @return mixed The data for the form.
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
* @since version
|
* @since version
|
||||||
*/
|
*/
|
||||||
protected function loadFormData(): mixed
|
protected function loadFormData(): mixed
|
||||||
@ -35,7 +47,8 @@ class AccessTokenModel extends AdminModel implements RevokedModelInterface
|
|||||||
// Check the session for previously entered form data.
|
// Check the session for previously entered form data.
|
||||||
$data = Factory::getApplication()->getUserState('com_oauthserver.edit.access_token.data', []);
|
$data = Factory::getApplication()->getUserState('com_oauthserver.edit.access_token.data', []);
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data))
|
||||||
|
{
|
||||||
$data = $this->getItem();
|
$data = $this->getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +58,30 @@ class AccessTokenModel extends AdminModel implements RevokedModelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Webmasterskaya\Component\OauthServer\Administrator\Table\AccessTokenTable $table
|
* @param \Webmasterskaya\Component\OauthServer\Administrator\Table\AccessTokenTable $table
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @since version
|
* @since version
|
||||||
*/
|
*/
|
||||||
protected function prepareTable($table)
|
protected function prepareTable($table)
|
||||||
{
|
{
|
||||||
if ($table->expiry instanceof \DateTime || $table->expiry instanceof \DateTimeImmutable) {
|
if ($table->expiry instanceof \DateTime || $table->expiry instanceof \DateTimeImmutable)
|
||||||
|
{
|
||||||
$table->expiry = $table->expiry->format($table->getDbo()->getDateFormat());
|
$table->expiry = $table->expiry->format($table->getDbo()->getDateFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $prefix
|
||||||
|
* @param $options
|
||||||
|
*
|
||||||
|
* @return bool|Table|AccessTokenTable
|
||||||
|
* @throws \Exception
|
||||||
|
* @since version
|
||||||
|
*/
|
||||||
public function getTable($name = 'AccessToken', $prefix = 'Administrator', $options = [])
|
public function getTable($name = 'AccessToken', $prefix = 'Administrator', $options = [])
|
||||||
{
|
{
|
||||||
return parent::getTable($name, $prefix, $options);
|
return parent::getTable($name, $prefix, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user