/**
  * Gets the model query
  * @param joppa\content\model\ContentProperties $contentProperties
  * @param zibo\library\orm\model\Model $model
  * @param string $locale Code of the locale
  * @param string $id The id of the record to fetch
  * @return zibo\library\orm\query\ModelQuery
  */
 private function getModelQuery(ContentProperties $contentProperties, $model, $locale, $id)
 {
     $includeUnlocalizedData = $contentProperties->getIncludeUnlocalized();
     $query = $model->createQuery($contentProperties->getRecursiveDepth(), $locale, $includeUnlocalizedData);
     $modelFields = $contentProperties->getModelFields();
     if ($modelFields) {
         foreach ($modelFields as $fieldName) {
             $query->addFields('{' . $fieldName . '}');
         }
     }
     $idField = $contentProperties->getParameterId();
     $query->addCondition('{' . $idField . '} = %1%', $id);
     $condition = $contentProperties->getCondition();
     if ($condition) {
         $query->addCondition($condition);
     }
     $order = $contentProperties->getOrder();
     if ($order) {
         $query->addOrderBy($order);
     }
     return $query;
 }