Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
521e1e59
Commit
521e1e59
authored
May 27, 2013
by
alexpott
Browse files
Issue
#1957158
by abghosh82, JacobSanford: Replace typed_data() with Drupal::typedData().
parent
b0f09bb6
Changes
13
Hide whitespace changes
Inline
Side-by-side
core/includes/bootstrap.inc
View file @
521e1e59
...
...
@@ -2288,27 +2288,6 @@ function state() {
return
drupal_container
()
->
get
(
'keyvalue'
)
->
get
(
'state'
);
}
/**
* Returns the typed data manager service.
*
* Use the typed data manager service for creating typed data objects.
*
* @see Drupal\Core\TypedData\TypedDataManager::create()
*
* @return Drupal\Core\TypedData\TypedDataManager
*/
function
typed_data
()
{
// Use the advanced drupal_static() pattern, since this is called very often.
static
$drupal_static_fast
;
if
(
!
isset
(
$drupal_static_fast
))
{
$drupal_static_fast
[
'manager'
]
=
&
drupal_static
(
__FUNCTION__
);
}
if
(
!
isset
(
$drupal_static_fast
[
'manager'
]))
{
$drupal_static_fast
[
'manager'
]
=
drupal_container
()
->
get
(
'typed_data'
);
}
return
$drupal_static_fast
[
'manager'
];
}
/**
* Returns the test prefix if this is an internal request from SimpleTest.
*
...
...
core/lib/Drupal/Core/Entity/EntityNG.php
View file @
521e1e59
...
...
@@ -170,8 +170,7 @@ protected function getTranslatedField($property_name, $langcode) {
if
(
isset
(
$this
->
values
[
$property_name
][
$langcode
]))
{
$value
=
$this
->
values
[
$property_name
][
$langcode
];
}
// @todo: Make entities implement the TypedDataInterface.
$this
->
fields
[
$property_name
][
$langcode
]
=
typed_data
()
->
getPropertyInstance
(
$this
,
$property_name
,
$value
);
$this
->
fields
[
$property_name
][
$langcode
]
=
\
Drupal
::
typedData
()
->
getPropertyInstance
(
$this
,
$property_name
,
$value
);
}
}
return
$this
->
fields
[
$property_name
][
$langcode
];
...
...
@@ -317,7 +316,7 @@ public function getTranslation($langcode, $strict = TRUE) {
'bundle'
=>
$this
->
bundle
(),
),
);
$translation
=
typed
_d
ata
()
->
create
(
$translation_definition
,
$fields
);
$translation
=
\
Drupal
::
typed
D
ata
()
->
create
(
$translation_definition
,
$fields
);
$translation
->
setStrictMode
(
$strict
);
$translation
->
setContext
(
'@'
.
$langcode
,
$this
);
return
$translation
;
...
...
core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
View file @
521e1e59
...
...
@@ -147,7 +147,7 @@ public function save(EntityInterface $entity);
* @return array
* An array of field definitions of entity fields, keyed by field
* name. In addition to the typed data definition keys as described at
* typed
_d
ata()->create() the follow keys are supported:
*
\Drupal::
typed
D
ata()->create() the follow keys are supported:
* - queryable: Whether the field is queryable via QueryInterface.
* Defaults to TRUE if 'computed' is FALSE or not set, to FALSE otherwise.
* - translatable: Whether the field is translatable. Defaults to FALSE.
...
...
@@ -155,7 +155,7 @@ public function save(EntityInterface $entity);
* via field.module. Defaults to FALSE.
*
* @see Drupal\Core\TypedData\TypedDataManager::create()
* @see typed
_d
ata()
* @see
\Drupal::
typed
D
ata()
*/
public
function
getFieldDefinitions
(
array
$constraints
);
...
...
core/lib/Drupal/Core/Entity/Field/FieldItemBase.php
View file @
521e1e59
...
...
@@ -31,7 +31,7 @@ public function __construct(array $definition, $name = NULL, TypedDataInterface
// with the whole item.
foreach
(
$this
->
getPropertyDefinitions
()
as
$name
=>
$definition
)
{
if
(
!
empty
(
$definition
[
'computed'
]))
{
$this
->
properties
[
$name
]
=
typed
_d
ata
()
->
getPropertyInstance
(
$this
,
$name
);
$this
->
properties
[
$name
]
=
\
Drupal
::
typed
D
ata
()
->
getPropertyInstance
(
$this
,
$name
);
}
}
}
...
...
core/lib/Drupal/Core/Executable/ExecutablePluginBase.php
View file @
521e1e59
...
...
@@ -95,7 +95,7 @@ public function getConfig() {
*/
public
function
setConfig
(
$key
,
$value
)
{
if
(
$definition
=
$this
->
getConfigDefinition
(
$key
))
{
$typed_data
=
typed
_d
ata
()
->
create
(
$definition
,
$value
);
$typed_data
=
\
Drupal
::
typed
D
ata
()
->
create
(
$definition
,
$value
);
if
(
$typed_data
->
validate
()
->
count
()
>
0
)
{
throw
new
PluginException
(
"The provided configuration value does not pass validation."
);
...
...
core/lib/Drupal/Core/Plugin/Context/Context.php
View file @
521e1e59
...
...
@@ -49,7 +49,7 @@ public function getContextValue() {
public
function
setContextValue
(
$value
)
{
// Make sure the value set is a typed data object.
if
(
!
empty
(
$this
->
contextDefinition
[
'type'
])
&&
!
$value
instanceof
TypedDataInterface
)
{
$value
=
typed
_d
ata
()
->
create
(
$this
->
contextDefinition
,
$value
);
$value
=
\
Drupal
::
typed
D
ata
()
->
create
(
$this
->
contextDefinition
,
$value
);
}
parent
::
setContextValue
(
$value
);
}
...
...
core/lib/Drupal/Core/TypedData/ItemList.php
View file @
521e1e59
...
...
@@ -133,7 +133,7 @@ public function offsetGet($offset) {
* @return \Drupal\Core\TypedData\TypedDataInterface
*/
protected
function
createItem
(
$offset
=
0
,
$value
=
NULL
)
{
return
typed
_d
ata
()
->
getPropertyInstance
(
$this
,
$offset
,
$value
);
return
\
Drupal
::
typed
D
ata
()
->
getPropertyInstance
(
$this
,
$offset
,
$value
);
}
/**
...
...
core/lib/Drupal/Core/TypedData/Type/Map.php
View file @
521e1e59
...
...
@@ -116,7 +116,7 @@ public function get($property_name) {
$value
=
$this
->
values
[
$property_name
];
}
// If the property is unknown, this will throw an exception.
$this
->
properties
[
$property_name
]
=
typed
_d
ata
()
->
getPropertyInstance
(
$this
,
$property_name
,
$value
);
$this
->
properties
[
$property_name
]
=
\
Drupal
::
typed
D
ata
()
->
getPropertyInstance
(
$this
,
$property_name
,
$value
);
}
return
$this
->
properties
[
$property_name
];
}
...
...
core/lib/Drupal/Core/TypedData/TypedData.php
View file @
521e1e59
...
...
@@ -100,7 +100,7 @@ public function getString() {
*/
public
function
getConstraints
()
{
// @todo: Add the typed data manager as proper dependency.
return
typed
_d
ata
()
->
getConstraints
(
$this
->
definition
);
return
\
Drupal
::
typed
D
ata
()
->
getConstraints
(
$this
->
definition
);
}
/**
...
...
@@ -108,7 +108,7 @@ public function getConstraints() {
*/
public
function
validate
()
{
// @todo: Add the typed data manager as proper dependency.
return
typed
_d
ata
()
->
getValidator
()
->
validate
(
$this
);
return
\
Drupal
::
typed
D
ata
()
->
getValidator
()
->
validate
(
$this
);
}
/**
...
...
core/lib/Drupal/Core/TypedData/TypedDataManager.php
View file @
521e1e59
...
...
@@ -130,7 +130,7 @@ public function createInstance($plugin_id, array $configuration, $name = NULL, $
* @return \Drupal\Core\TypedData\TypedDataInterface
* The instantiated typed data object.
*
* @see typed
_d
ata()
* @see
\Drupal::
typed
D
ata()
* @see \Drupal\Core\TypedData\TypedDataManager::getPropertyInstance()
* @see \Drupal\Core\TypedData\Type\Integer
* @see \Drupal\Core\TypedData\Type\Float
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
View file @
521e1e59
...
...
@@ -358,7 +358,7 @@ protected function assertIntrospection($entity_type) {
),
'label'
=>
'Test entity'
,
);
$wrapped_entity
=
typed_data
(
)
->
create
(
$definition
);
$wrapped_entity
=
$this
->
container
->
get
(
'
typed_data
'
)
->
create
(
$definition
);
$definitions
=
$wrapped_entity
->
getPropertyDefinitions
(
$definition
);
$this
->
assertEqual
(
$definitions
[
'name'
][
'type'
],
'string_field'
,
$entity_type
.
': Name field found.'
);
$this
->
assertEqual
(
$definitions
[
'user_id'
][
'type'
],
'entity_reference_field'
,
$entity_type
.
': User field found.'
);
...
...
@@ -478,7 +478,7 @@ protected function assertDataStructureInterfaces($entity_type) {
),
'label'
=>
'Test entity'
,
);
$wrapped_entity
=
typed_data
(
)
->
create
(
$entity_definition
,
$entity
);
$wrapped_entity
=
$this
->
container
->
get
(
'
typed_data
'
)
->
create
(
$entity_definition
,
$entity
);
// Test using the whole tree of typed data by navigating through the tree of
// contained properties and getting all contained strings, limited by a
...
...
@@ -539,7 +539,7 @@ public function testEntityConstraintValidation() {
),
'label'
=>
'Test entity'
,
);
$wrapped_entity
=
typed_data
(
)
->
create
(
$entity_definition
,
$entity
);
$wrapped_entity
=
$this
->
container
->
get
(
'
typed_data
'
)
->
create
(
$entity_definition
,
$entity
);
// Test validation the typed data object.
$violations
=
$wrapped_entity
->
validate
();
...
...
@@ -567,7 +567,7 @@ public function testEntityConstraintValidation() {
),
'label'
=>
'Test node'
,
);
$wrapped_entity
=
typed_data
(
)
->
create
(
$entity_definition
,
$node
);
$wrapped_entity
=
$this
->
container
->
get
(
'
typed_data
'
)
->
create
(
$entity_definition
,
$node
);
$violations
=
$wrapped_entity
->
validate
();
$this
->
assertEqual
(
$violations
->
count
(),
1
);
...
...
core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php
View file @
521e1e59
...
...
@@ -42,7 +42,7 @@ public function setUp() {
parent
::
setup
();
$this
->
installSchema
(
'file'
,
array
(
'file_managed'
,
"file_usage"
));
$this
->
typedData
=
typed_data
(
);
$this
->
typedData
=
$this
->
container
->
get
(
'
typed_data
'
);
}
/**
...
...
@@ -54,7 +54,7 @@ protected function createTypedData($definition, $value = NULL, $name = NULL) {
// Save the type that was passed in so we can compare with it later.
$type
=
$definition
[
'type'
];
// Construct the object.
$data
=
typed
_d
ata
()
->
create
(
$definition
,
$value
,
$name
);
$data
=
$this
->
typed
D
ata
->
create
(
$definition
,
$value
,
$name
);
// Assert the definition of the wrapper.
$this
->
assertTrue
(
$data
instanceof
\
Drupal\Core\TypedData\TypedDataInterface
,
'Typed data object is an instance of the typed data interface.'
);
$definition
=
$data
->
getDefinition
();
...
...
core/modules/system/system.api.php
View file @
521e1e59
...
...
@@ -167,7 +167,7 @@ function hook_cron() {
* - constraints: An array of validation constraints for this type. See
* \Drupal\Core\TypedData\TypedDataManager::getConstraints() for details.
*
* @see typed
_d
ata()
* @see
\Drupal::
typed
D
ata()
* @see Drupal\Core\TypedData\TypedDataManager::create()
* @see hook_data_type_info_alter()
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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