Archived
1
0
Fork 0

app/View/Components/CardText.php: Add optional $subject parameter and if empty we take $card->subject

This commit is contained in:
Henrik Hautakoski 2022-01-15 14:14:01 +01:00
parent b5c61cb159
commit f91216c983

View file

@ -10,14 +10,17 @@ class CardText extends Component
{ {
protected Card $card; protected Card $card;
protected string $subject;
/** /**
* Create a new component instance. * Create a new component instance.
* *
* @return void * @return void
*/ */
public function __construct(Card $card) public function __construct(Card $card, $subject = '')
{ {
$this->card = $card; $this->card = $card;
$this->subject = strlen($subject) ? $subject : $card->subject;
} }
/** /**
@ -27,7 +30,7 @@ class CardText extends Component
*/ */
public function render() public function render()
{ {
$subject = preg_quote(__($this->card->subject)); $subject = preg_quote(__($this->subject));
// Replace non escaped '?' with subject and also Unescape escaped '?' // Replace non escaped '?' with subject and also Unescape escaped '?'
$text = preg_replace( $text = preg_replace(