コード例 #1
0
 /**
  * Gets an existing text from the data source
  * @param \ride\library\widget\WidgetProperties $widgetProperties Instance
  * of the widget properties
  * @param string $locale Code of the current locale
  * @param string $textId Identifier of the text
  * @param boolean $isNew Flag to see if this text will be a new text
  * @return \ride\web\cms\text\Text Instance of the text
  */
 public function getExistingText(WidgetProperties $widgetProperties, $locale, $textId, $isNew)
 {
     $textModel = $this->orm->getTextModel();
     $text = null;
     if ($textId) {
         $query = $textModel->createQuery($locale);
         $query->setIncludeUnlocalized(true);
         $query->addCondition('{id} = %1%', $textId);
         $text = $query->queryFirst();
     }
     if (!$text) {
         $text = $textModel->createEntry();
         $text->setLocale($locale);
     }
     return $text;
 }