/**
  * Stores the text in the data source
  * @param \ride\library\widget\WidgetProperties $widgetProperties Instance
  * of the widget properties
  * @param string|array $locales Code of the current locale
  * @param \ride\web\cms\text\Text $text Instance of the text
  * @param array $data Submitted data
  * @return null
  */
 public function setText(WidgetProperties $widgetProperties, $locales, Text $text, array $data)
 {
     if (!is_array($locales)) {
         $locales = array($locales);
     }
     foreach ($locales as $locale) {
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_FORMAT, $text->getFormat());
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_TITLE, $data[TextWidget::PROPERTY_TITLE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_SUBTITLE, $data[TextWidget::PROPERTY_SUBTITLE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_BODY, $data[TextWidget::PROPERTY_BODY]);
         $widgetProperties->setLocalizedWidgetProperty($locale, str_replace('-', '.', TextWidget::PROPERTY_IMAGE), $data[TextWidget::PROPERTY_IMAGE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, str_replace('-', '.', TextWidget::PROPERTY_IMAGE_ALIGNMENT), $data[TextWidget::PROPERTY_IMAGE_ALIGNMENT]);
         $widgetProperties->clearWidgetProperties(TextWidget::PROPERTY_CTA . '.' . $locale);
         $index = 1;
         foreach ($data[TextWidget::PROPERTY_CTA] as $cta) {
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.label', $cta['label']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.node', $cta['node']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.url', $cta['url']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.type', $cta['type']);
             $index++;
         }
     }
 }