ParagraphSetterTrait::setParagraph

@param string $text

@return static
162442
public function setParagraph($text)
    {
        $this->paragraph = new Paragraph();
        $this->paragraph->entity->setEntityName('paragraph');
        $this->paragraph->textContent->push($text);

        return $this;
    }
1118395
public function format($text)
    {
        preg_match_all(self::REGEX_PLACEHOLDER, $text, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            $uid = (int)$match[1];
            //meh, fix the following lines late
            $parent = $this->findParentFromDataUid($uid);
            $el = $this->findItemFromUid($uid);
            $node = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceNode')
                ->findOneBy(
                    array(
                        'parent' => $parent,
                        'name' => $el['name'],
                        'resourceType' => $this->resourceManager->getResourceTypeByName($el['type'])
                    )
                );

            if ($node) {
                $toReplace = $this->generateDisplayedUrlForTinyMce($node);
                $text = str_replace($match[0], $toReplace, $text);
            }
        }

        $event = $this->eventDispatcher->dispatch(
            'rich_text_format_event_import',
            'RichTextFormat',
            array($text)
        );

        return $event->getText();
    }
1009744
public function setText(string $text)
    {
        if (strlen($text) == 0) {
            throw new LengthException("Empty token content");
        }
        $this->text = $text;
        return $this;
    }
802850
public function setTexts(array $texts)
    {
        $this->texts = array_map(function ($text) {
            return preg_replace('/\R/', PHP_EOL, $text);
        }, array_merge($this->texts, $texts));
        return $this;
    }
479417
protected function onSetText(string $text): void
    {
        parent::onSetText($text);

        $this->isInvalid = false;
        $this->value = null;

        if ($this->hasError()) {
            return;
        }

        if ($this->isEmpty()) {
            return;
        }

        try {
            $this->setValue(new \DateTimeImmutable($text));
        } catch (\Exception $exception) {
            $this->setError('Invalid value');
            $this->isInvalid = true;
        }
    }
702091
public function setText(string $text=null, bool $append=true) :self {
		// append by default or replace text
		$this->content = $append ? $this->content . Format::htmlSafe($text) : Format::htmlSafe($text);
		// return self
		return($this);
	}
122034
public function setText(string $text)
    {
        $this
            ->getLexer()
            ->setText($text);
        $this->locator = null;
        return $this;
    }
443081
protected function processBlock($text)
    {
        // Process heading
        if (preg_match(self::MATCH_HEADING, $text, $matches)) {
            return $this->addHeading(strlen($matches[1]), $matches[2]);
        }

        if (preg_match(self::MATCH_HR, $text)) {
            return $this->addHorizontalRule($text);
        }

        if (mb_substr($text, 0, 2) === self::BLOCKQUOTE_START) {
            return $this->processBlockquote($text);
        }

        // nothing found wrap in paragraph
        return $this->processParagraph($text);
   }
846211
public function setTextBody($text) {
    if (!is_string($text)) {
      $error = sprintf("Plain text given is not a string (Actual type: %s).",
                       gettype($text));
      throw new \InvalidArgumentException($error);
    }
    $this->message->setTextbody($text);
  }
69922
public ParagraphBuilder span(final String text) {
		final ParagraphElement paragraphElement = new Span(text);
		this.paragraphElements.add(paragraphElement);
		return this;
	}
628787
public function FirstParagraph()
    {
        $value = $this->Plain();
        if (empty($value)) {
            return '';
        }

        // Split paragraphs and return first
        $paragraphs = preg_split('#\n{2,}#', $value);
        return reset($paragraphs);
    }
548625
public function loadGrammar(string $text): Grammar
    {
        $this->symbols = [];
        $this->inline = [];
        $this->regexpMap = [];
        $this->defines = [];
        $this->whitespaces = [];
        $this->modifiers = null;

        try {
            /** @var Rule[] $rules */
            $rules = $this->parser->parse($text, $this->actions)->made();

            /** @var int[] $subject_rules_count */
            $subject_rules_count = [];
            /** @var int[] $inline_ref_count */
            $inline_ref_count = [];
            /** @var Rule[] $inline_ref_rule */
            $inline_ref_rule = [];

            $non_terminal_is_hidden = [];
            $hidden_non_terminals = [];

            foreach ($rules as $rule) {
                $subject = $rule->getSubject();
                $subject_name = $subject->getName();
                $subject_hidden = $subject->isHidden();

                // RegExp tokens cannot be non-terminals in the same time
                // since there is no anonymous RegExp terminals
                if (isset($this->regexpMap[$subject_name])) {
                    throw new GrammarException(
                        "Symbol `$subject_name` defined as non-terminal and as regexp terminal in the same time"
                    );
                }

                if (isset($non_terminal_is_hidden[$subject_name])) {
                    if ($subject_hidden !== $non_terminal_is_hidden[$subject_name]) {
                        throw new GrammarException(
                            "Symbol `$subject_name` defined both as hidden and as visible"
                        );
                    }
                } else {
                    $non_terminal_is_hidden[$subject_name] = $subject_hidden;
                }

                $subject_rules_count[$subject_name] = ($subject_rules_count[$subject_name] ?? 0) + 1;

                if ($subject_hidden) {
                    $hidden_non_terminals[$subject_name] = true;
                }

                foreach ($rule->getDefinition() as $symbol) {
                    $name = $symbol->getName();
                    if (isset($this->inline[$name])) {
                        $inline_ref_count[$name] = ($inline_ref_count[$name] ?? 0) + 1;

                        // it is needed in case of the only reference,
                        // so array of an subject is not needed
                        $inline_ref_rule[$name] = $rule;
                    }
                }
            }

            foreach ($hidden_non_terminals as $name => $_) {
                if (isset($this->symbols[$name][false])) {
                    $this->symbols[$name][false]->setIsHidden(true);
                }
            }

            // Convert non-terminals defined only once with inline tokens
            // `Subject: "inline"`
            // into fixed terminals
            $fixed = [];
            foreach ($inline_ref_count as $inline_token => $ref_count) {
                if (1 !== $ref_count) {
                    continue;
                }

                $rule = $inline_ref_rule[$inline_token];
                if (null === $rule->getTag() && 1 === count($rule->getDefinition())) {
                    $subject = $rule->getSubject();
                    $name = $subject->getName();

                    if (1 !== $subject_rules_count[$name]) {
                        continue;
                    }

                    // remove rule
                    $key = array_search($rule, $rules, true);
                    if (false !== $key) {
                        unset($rules[$key]);
                    }

                    // remove inline
                    unset($this->inline[$inline_token]);

                    // make terminal
                    $subject->setIsTerminal(true);
                    if (isset($this->symbols[$name][!$subject->isHidden()])) {
                        $this->symbols[$name][!$subject->isHidden()]->setIsTerminal(true);
                    }

                    $fixed[$name] = $inline_token;
                }
            }

            return new Grammar(
                $rules,
                $this->inline,
                $fixed,
                $this->regexpMap,
                $this->whitespaces,
                $this->defines,
                $this->modifiers ?? ''
            );
        } catch (UnknownCharacterException | UnexpectedInputAfterEndException | UnexpectedTokenException $e) {
            throw new GrammarException(
                'Cannot parse grammar: ' . $e->getMessage() . ' at offset ' . $e->getOffset(),
                0,
                $e
            );
        } catch (AbortedException $e) {
            for ($inner = $e; $inner; $inner = $inner->getPrevious()) {
                if ($inner instanceof GrammarException || $inner instanceof InternalException) {
                    throw $inner;
                }
            }
            throw new InternalException('Failure while parsing your grammar text', 0, $e);
        } finally {
            $this->symbols = null;
            $this->inline = null;
            $this->regexpMap = null;
            $this->defines = null;
            $this->whitespaces = null;
            $this->modifiers = null;
        }
    }
14750
public function setBody($text)
    {
        if (is_string($text)) {
            $this->lines = explode("\n", $text);
        } elseif (is_array($text)) {
            $this->lines = $text;
        } else {
            throw new InvalidArgumentTypeException('Invalid body type', $text, array('string', 'array'));
        }
    }
110938
public function setTitle(string $text = null): ButtonInterface
    {
        if ($this->isVisibility()) {
            $this->title = $text;
        }

        return $this;
    }
1121422
public function setDescription($text)
    {
        if (is_array($text)) {
            $text = implode("\n", $text);
        }
        $this->_description = $text;

        return $this;
    }
153332
protected function reset($text)
	{
		// Reject invalid UTF-8
		if (!preg_match('//u', $text))
		{
			throw new InvalidArgumentException('Invalid UTF-8 input');
		}

		// Normalize CR/CRLF to LF, remove control characters that aren't allowed in XML
		$text = preg_replace('/\\r\\n?/', "\n", $text);
		$text = preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]+/S', '', $text);

		// Clear the logs
		$this->logger->clear();

		// Initialize the rest
		$this->cntOpen           = [];
		$this->cntTotal          = [];
		$this->currentFixingCost = 0;
		$this->currentTag        = null;
		$this->isRich            = false;
		$this->namespaces        = [];
		$this->openTags          = [];
		$this->output            = '';
		$this->pos               = 0;
		$this->tagStack          = [];
		$this->tagStackIsSorted  = false;
		$this->text              = $text;
		$this->textLen           = strlen($text);
		$this->wsPos             = 0;

		// Initialize the root context
		$this->context = $this->rootContext;
		$this->context['inParagraph'] = false;

		// Bump the UID
		++$this->uid;
	}
1291230
public function text($text = '')
    {
        $msg = array(
            'ToUserName'   => $this->getRevFrom(),
            'FromUserName' => $this->getRevTo(),
            'MsgType'      => self::MSGTYPE_TEXT,
            'Content'      => $this->_auto_text_filter($text),
            'CreateTime'   => time(),
        );
        $this->Message($msg);
        return $this;
    }