Commit 718c503a authored by alexpott's avatar alexpott

Issue #2586047 by willzyx: Fatal error: Call to a member function getFieldStorageDefinition()

parent 96808b3a
......@@ -13,6 +13,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field_ui\FieldUI;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Provides a form for the "field storage" edit page.
......@@ -33,6 +34,9 @@ public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entit
// The URL of this entity form contains only the ID of the field_config
// but we are actually editing a field_storage_config entity.
$field_config = FieldConfig::load($route_match->getRawParameter('field_config'));
if (!$field_config) {
throw new NotFoundHttpException();
}
return $field_config->getFieldStorageDefinition();
}
......
......@@ -718,4 +718,17 @@ public function testPreconfiguredFields() {
$this->assertEqual($view_display->getComponent('field_test_custom_options')['type'], 'field_test_multiple');
}
/**
* Tests the access to non-existent field URLs.
*/
public function testNonExistentFieldUrls() {
$field_id = 'node.foo.bar';
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$this->assertResponse(404);
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id . '/storage');
$this->assertResponse(404);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment