55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
// Authors: see README.md
|
|
|
|
use SeaCMS\Api\ApiAware;
|
|
use SeaCMS\Api\JsonResponse;
|
|
|
|
/**
|
|
* authentification plugin for Pico 3.
|
|
*/
|
|
class SeacmsAuth extends AbstractPicoPlugin implements ApiAware
|
|
{
|
|
/**
|
|
* Pico API version.
|
|
* @var int
|
|
*/
|
|
const API_VERSION = 4;
|
|
|
|
/**
|
|
* return api routes
|
|
* @return array
|
|
*/
|
|
public function registerApiRoutes():array
|
|
{
|
|
return [
|
|
'GET login/isConnected' => 'apiIsConnected',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* method for api
|
|
* @return JsonResponse
|
|
*/
|
|
public function apiIsConnected(): JsonResponse
|
|
{
|
|
return new JsonResponse(200,['connected'=>false]);
|
|
}
|
|
|
|
/**
|
|
* Triggered when Pico registers the twig template engine
|
|
*
|
|
* @see Pico::getTwig()
|
|
*
|
|
* @param Twig_Environment &$twig Twig instance
|
|
*/
|
|
public function onTwigRegistered(Twig_Environment &$twig)
|
|
{
|
|
$twigLoader = $twig->getLoader();
|
|
$templateDir = $this->getPluginsDir().'SeacmsAuth/templates';
|
|
if (is_dir($templateDir)){
|
|
$twigLoader->addPath($templateDir, 'SeacmsAuth');
|
|
}
|
|
}
|
|
}
|