Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adding 'dir' attribute to all paragraphs (UNTESTED)
// TODO: Set your "namespace" and "use" statements here
// Also see this documentation:
class ParagraphDirProcessor implements DocumentProcessorInterface
public function processDocument(Document $document)
$walker = $document->walker();
while ($event = $walker->next()) {
$node = $event->getNode();
// Only stop at Paragraph nodes when we first encounter them
if (!($node instanceof Paragraph) || !$event->isEntering()) {
$node->data['attributes']['dir'] = 'rtl';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.