/**
  * Reads the content mappers for the content detail widgets
  * @return array
  */
 public function readContentMappers()
 {
     $this->mappers = array();
     $this->defaultMappers = array();
     $entryFormatter = $this->orm->getEntryFormatter();
     $nodes = $this->nodeModel->getNodesForWidget('orm.detail');
     foreach ($nodes as $node) {
         $widgetId = $node->getWidgetId();
         if (!$widgetId) {
             continue;
         }
         $widgetProperties = $node->getWidgetProperties($widgetId);
         $modelName = $widgetProperties->getWidgetProperty(ContentProperties::PROPERTY_MODEL_NAME);
         if (!$modelName) {
             continue;
         }
         if (!isset($mappers[$modelName])) {
             $mappers[$modelName] = array();
         }
         $model = $this->orm->getModel($modelName);
         $mapperId = $node->getId() . '-' . $widgetId;
         $this->mappers[$modelName][$mapperId] = new GenericOrmContentMapper($this->nodeModel, $node, $model, $entryFormatter, $widgetProperties, $this->routerService);
         if ($widgetProperties->getWidgetProperty(ContentProperties::PROPERTY_PRIMARY)) {
             $this->defaultMappers[$modelName] = $mapperId;
         }
     }
     foreach ($this->mappers as $modelName => $modelMappers) {
         if (!isset($this->defaultMappers[$modelName])) {
             reset($modelMappers);
             $this->defaultMappers[$modelName] = key($modelMappers);
         }
     }
     return $this->mappers;
 }
 /**
  * Adds a warning to the response if the provided text is used in another
  * widget instance
  * @param \ride\library\widget\WidgetProperties $widgetProperties
  * @param \ride\web\cms\orm\model\TextModel $textModel
  * @param \ride\web\cms\text\Text $text Instance of the text
  * @param string $warning
  * @return null
  */
 protected function warnAboutUsedText(WidgetProperties $widgetProperties, TextModel $textModel, Text $text, $warning)
 {
     if (!$text->id) {
         return;
     }
     $widgetId = $widgetProperties->getWidgetId();
     $node = $widgetProperties->getNode();
     $rootNode = $node->getRootNode();
     $nodes = $this->nodeModel->getNodesForWidget(TextWidget::NAME, $rootNode->getId());
     foreach ($nodes as $node) {
         $nodeWidgetId = $node->getWidgetId();
         if ($nodeWidgetId == $widgetId) {
             continue;
         }
         $nodeWidgetProperties = $node->getWidgetProperties($nodeWidgetId);
         if ($nodeWidgetProperties->getWidgetProperty(TextWidget::PROPERTY_IO) !== self::NAME) {
             continue;
         }
         if ($nodeWidgetProperties->getWidgetProperty(TextWidget::PROPERTY_TEXT) !== $text->id) {
             continue;
         }
         $message = new Message($warning, Message::TYPE_WARNING);
         $this->response->addMessage($message);
         break;
     }
 }
 /**
  * Constructs a new decorator
  * @return null
  */
 public function __construct(NodeModel $nodeModel, $locale, $nodeUrl)
 {
     $this->nodes = $nodeModel->getNodesForWidget('text');
     $this->locale = $locale;
     $this->url = $nodeUrl;
 }