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

8.1.x
Alex Pott 2015-12-09 16:53:32 +00:00
parent 96808b3a38
commit 718c503a52
2 changed files with 17 additions and 0 deletions

View File

@ -13,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface;
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 @@ class FieldStorageConfigEditForm extends EntityForm {
// 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();
}

View File

@ -718,4 +718,17 @@ class ManageFieldsTest extends WebTestBase {
$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);
}
}