예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function renameField($old_field_id, $new_field_id)
 {
     if (!isset($this->getFields()[$old_field_id])) {
         $args['%field_id'] = $old_field_id;
         throw new SearchApiException(new FormattableMarkup('Could not rename field with machine name %field_id: no such field.', $args));
     }
     if (Utility::isFieldIdReserved($new_field_id)) {
         $args['%field_id'] = $new_field_id;
         throw new SearchApiException(new FormattableMarkup('%field_id is a reserved value and cannot be used as the machine name of a normal field.', $args));
     }
     if (isset($this->getFields()[$new_field_id])) {
         $args['%field_id'] = $new_field_id;
         throw new SearchApiException(new FormattableMarkup("%field_id already exists and can't be used as a new field id.", $args));
     }
     $this->fieldInstances[$new_field_id] = $this->fieldInstances[$old_field_id];
     unset($this->fieldInstances[$old_field_id]);
     return $this;
 }