OEModule\PatientTicketing\components\Substitution::replace PHP 메소드

replace() 공개 정적인 메소드

public static replace ( $text, $patient ) : mixed
$text
$patient
리턴 mixed
    public static function replace($text, $patient)
    {
        preg_match_all('/\\[([a-z]{3})\\]/is', $text, $m);
        foreach ($m[1] as $el) {
            $count = \PatientShortcode::model()->count('code=?', array(strtolower($el)));
            if ($count == 1) {
                if ($code = \PatientShortcode::model()->find('code=?', array(strtolower($el)))) {
                    $text = $code->replaceText($text, $patient, (bool) preg_match('/^[A-Z]/', $el));
                }
            } elseif ($count > 1) {
                throw new \Exception("Multiple shortcode definitions for {$el}");
            }
        }
        return $text;
    }

Usage Example

예제 #1
0
 public function generateReportText()
 {
     $this->report = \OEModule\PatientTicketing\components\Substitution::replace($this->replaceAssignmentCodes($this->queue->report_definition), $this->ticket->patient);
 }
Substitution