diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php index 0cf3281215bea96a792ee95ef2c198ea0d46a431..ef160782272fd9567ac3ad6f3743bb5323de6329 100644 --- a/core/modules/rest/src/Plugin/ResourceBase.php +++ b/core/modules/rest/src/Plugin/ResourceBase.php @@ -87,7 +87,7 @@ public function permissions() { foreach ($this->availableMethods() as $method) { $lowered_method = strtolower($method); $permissions["restful $lowered_method $this->pluginId"] = array( - 'title' => t('Access @method on %label resource', array('@method' => $method, '%label' => $definition['label'])), + 'title' => $this->t('Access @method on %label resource', array('@method' => $method, '%label' => $definition['label'])), ); } return $permissions; diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 7b3e49e94258a3f711693ae1136138eddaf0cabf..c58ff1ad7e61a11f282fb08896220d552121fbfb 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\rest\Plugin\ResourceBase; use Drupal\rest\ResourceResponse; +use Drupal\Component\Utility\String; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -69,7 +70,7 @@ public function get(EntityInterface $entity) { */ public function post(EntityInterface $entity = NULL) { if ($entity == NULL) { - throw new BadRequestHttpException(t('No entity content received.')); + throw new BadRequestHttpException('No entity content received.'); } if (!$entity->access('create')) { @@ -79,16 +80,16 @@ public function post(EntityInterface $entity = NULL) { // Verify that the deserialized entity is of the type that we expect to // prevent security issues. if ($entity->getEntityTypeId() != $definition['entity_type']) { - throw new BadRequestHttpException(t('Invalid entity type')); + throw new BadRequestHttpException('Invalid entity type'); } // POSTed entities must not have an ID set, because we always want to create // new entities here. if (!$entity->isNew()) { - throw new BadRequestHttpException(t('Only new entities can be created')); + throw new BadRequestHttpException('Only new entities can be created'); } foreach ($entity as $field_name => $field) { if (!$field->access('create')) { - throw new AccessDeniedHttpException(t('Access denied on creating field @field.', array('@field' => $field_name))); + throw new AccessDeniedHttpException(String::format('Access denied on creating field ', array('@field' => $field_name))); } } @@ -103,7 +104,7 @@ public function post(EntityInterface $entity = NULL) { return new ResourceResponse(NULL, 201, array('Location' => $url)); } catch (EntityStorageException $e) { - throw new HttpException(500, t('Internal Server Error'), $e); + throw new HttpException(500, 'Internal Server Error', $e); } } @@ -122,11 +123,11 @@ public function post(EntityInterface $entity = NULL) { */ public function patch(EntityInterface $original_entity, EntityInterface $entity = NULL) { if ($entity == NULL) { - throw new BadRequestHttpException(t('No entity content received.')); + throw new BadRequestHttpException('No entity content received.'); } $definition = $this->getPluginDefinition(); if ($entity->getEntityTypeId() != $definition['entity_type']) { - throw new BadRequestHttpException(t('Invalid entity type')); + throw new BadRequestHttpException('Invalid entity type'); } if (!$original_entity->access('update')) { throw new AccessDeniedHttpException(); @@ -143,11 +144,11 @@ public function patch(EntityInterface $original_entity, EntityInterface $entity continue; } if ($field->isEmpty() && !$original_entity->get($field_name)->access('delete')) { - throw new AccessDeniedHttpException(t('Access denied on deleting field @field.', array('@field' => $field_name))); + throw new AccessDeniedHttpException(String::format('Access denied on deleting field ', array('@field' => $field_name))); } $original_entity->set($field_name, $field->getValue()); if (!$original_entity->get($field_name)->access('update')) { - throw new AccessDeniedHttpException(t('Access denied on updating field @field.', array('@field' => $field_name))); + throw new AccessDeniedHttpException(String::format('Access denied on updating field ', array('@field' => $field_name))); } } } @@ -162,7 +163,7 @@ public function patch(EntityInterface $original_entity, EntityInterface $entity return new ResourceResponse(NULL, 204); } catch (EntityStorageException $e) { - throw new HttpException(500, t('Internal Server Error'), $e); + throw new HttpException(500, 'Internal Server Error', $e); } } @@ -189,7 +190,7 @@ public function delete(EntityInterface $entity) { return new ResourceResponse(NULL, 204); } catch (EntityStorageException $e) { - throw new HttpException(500, t('Internal Server Error'), $e); + throw new HttpException(500, 'Internal Server Error', $e); } } diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php index 980f80c10eb83dc1e331c78dca7dc334ec17215b..71502f5399b806309b79e264b79366eee510007a 100644 --- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php +++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php @@ -79,7 +79,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['field_options'] = array( '#type' => 'table', - '#header' => array(t('Field'), $this->t('Alias'), $this->t('Raw output')), + '#header' => array($this->t('Field'), $this->t('Alias'), $this->t('Raw output')), '#empty' => $this->t('You have no fields. Add some to your view.'), '#tree' => TRUE, );