Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
66
vendor/doctrine/rst-parser/lib/HTML/Directives/Wrap.php
vendored
Normal file
66
vendor/doctrine/rst-parser/lib/HTML/Directives/Wrap.php
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\SubDirective;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
use RuntimeException;
|
||||
|
||||
use function uniqid;
|
||||
|
||||
/**
|
||||
* Wraps a sub document in a div with a given class
|
||||
*/
|
||||
final class Wrap extends SubDirective
|
||||
{
|
||||
/** @var string */
|
||||
private $class;
|
||||
|
||||
/** @var bool */
|
||||
private $uniqid;
|
||||
|
||||
public function __construct(string $class, bool $uniqid = false)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->uniqid = $uniqid;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processSub(
|
||||
Parser $parser,
|
||||
?Node $document,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
// if there is a "Wrap" directive (e.g. a note::), blank content is unexpected
|
||||
if ($document === null) {
|
||||
throw new RuntimeException('Content expected, none found.');
|
||||
}
|
||||
|
||||
if ($this->uniqid) {
|
||||
$id = uniqid($this->class);
|
||||
} else {
|
||||
$id = '';
|
||||
}
|
||||
|
||||
$divOpen = $parser->renderTemplate('div-open.html.twig', [
|
||||
'id' => $id,
|
||||
'class' => $this->class,
|
||||
]);
|
||||
|
||||
return $parser->getNodeFactory()->createWrapperNode(
|
||||
$document,
|
||||
$divOpen,
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue