mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 14:36:52 +00:00
Initial import
This commit is contained in:
commit
2295a33590
884 changed files with 93939 additions and 0 deletions
25
php/src/Twig/ClassExtension.php
Normal file
25
php/src/Twig/ClassExtension.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace AIO\Twig;
|
||||
|
||||
use Slim\Views\TwigExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class ClassExtension extends TwigExtension
|
||||
{
|
||||
public function getFunctions() : array
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('class', array($this, 'getClassName')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getClassName($object) : ?string
|
||||
{
|
||||
if (!is_object($object)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return get_class($object);
|
||||
}
|
||||
}
|
||||
38
php/src/Twig/CsrfExtension.php
Normal file
38
php/src/Twig/CsrfExtension.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace AIO\Twig;
|
||||
|
||||
use Slim\Csrf\Guard;
|
||||
|
||||
class CsrfExtension extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface
|
||||
{
|
||||
/**
|
||||
* @var Guard
|
||||
*/
|
||||
protected Guard $csrf;
|
||||
|
||||
public function __construct(Guard $csrf)
|
||||
{
|
||||
$this->csrf = $csrf;
|
||||
}
|
||||
|
||||
public function getGlobals() : array
|
||||
{
|
||||
// CSRF token name and value
|
||||
$csrfNameKey = $this->csrf->getTokenNameKey();
|
||||
$csrfValueKey = $this->csrf->getTokenValueKey();
|
||||
$csrfName = $this->csrf->getTokenName();
|
||||
$csrfValue = $this->csrf->getTokenValue();
|
||||
|
||||
return [
|
||||
'csrf' => [
|
||||
'keys' => [
|
||||
'name' => $csrfNameKey,
|
||||
'value' => $csrfValueKey
|
||||
],
|
||||
'name' => $csrfName,
|
||||
'value' => $csrfValue
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue