Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
fde84e2a
Commit
fde84e2a
authored
Jan 25, 2014
by
Alex Pott
Browse files
Issue
#2174509
by amateescu, chx: Drupal\Core\Field\FieldDefinition::getSchema() is broken.
parent
1b252e29
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Field/FieldDefinition.php
View file @
fde84e2a
...
...
@@ -24,6 +24,11 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface
*/
protected
$schema
;
/**
* @var array
*/
protected
$indexes
=
array
();
/**
* Creates a new field definition.
*
...
...
@@ -286,7 +291,7 @@ public function getDefaultValue(EntityInterface $entity) {
public
function
getSchema
()
{
if
(
!
isset
(
$this
->
schema
))
{
// Get the schema from the field item class.
$definition
=
\
Drupal
::
service
(
'plugin.manager.field.field_type'
)
->
getDefinition
(
$this
->
get
Field
Type
());
$definition
=
\
Drupal
::
service
(
'plugin.manager.field.field_type'
)
->
getDefinition
(
$this
->
getType
());
$class
=
$definition
[
'class'
];
$schema
=
$class
::
schema
(
$this
);
// Fill in default values for optional entries.
...
...
core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
View file @
fde84e2a
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\field\Tests
;
use
Drupal\Core\Field\FieldDefinition
;
use
Drupal\Core\Field\FieldItemInterface
;
use
Drupal\Core\Field\FieldItemListInterface
;
...
...
@@ -83,6 +84,23 @@ public function testTestItem() {
$entity
->
save
();
$entity
=
entity_load
(
'entity_test'
,
$id
);
$this
->
assertEqual
(
$entity
->
{
$this
->
field_name
}
->
value
,
$new_value
);
// Test the schema for this field type.
$expected_schema
=
array
(
'columns'
=>
array
(
'value'
=>
array
(
'type'
=>
'int'
,
'size'
=>
'medium'
,
'not null'
=>
FALSE
,
),
),
'indexes'
=>
array
(
'value'
=>
array
(
'value'
),
),
'foreign keys'
=>
array
(),
);
$field_schema
=
FieldDefinition
::
create
(
'test_field'
)
->
getSchema
();
$this
->
assertEqual
(
$field_schema
,
$expected_schema
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment