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
5b17c1eb
Commit
5b17c1eb
authored
Jun 30, 2009
by
Angie Byron
Browse files
#502522
by yched: Allow drupal_alter() on various Field API meta-hooks.
parent
6d5d8dcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/field/field.api.php
View file @
5b17c1eb
...
...
@@ -53,6 +53,19 @@ function hook_fieldable_info() {
return
$return
;
}
/**
* Perform alterations on fieldable types.
*
* @param $info
* Array of informations on fieldable types exposed by hook_fieldable_info()
* implementations.
*/
function
hook_fieldable_info_alter
(
&
$info
)
{
// A contributed module handling node-level caching would want to disable
// field cache for nodes.
$info
[
'node'
][
'cacheable'
]
=
FALSE
;
}
/**
* @} End of "ingroup field_fieldable_type"
*/
...
...
@@ -114,6 +127,25 @@ function hook_field_info() {
);
}
/**
* Perform alterations on Field API field types.
*
* @param $info
* Array of informations on widget types exposed by hook_field_info()
* implementations.
*/
function
hook_field_info_alter
(
&
$info
)
{
// Add a setting to all field types.
foreach
(
$info
as
$field_type
=>
$field_type_info
)
{
$info
[
$field_type
][
'settings'
][]
=
array
(
'mymodule_additional_setting'
=>
'default value'
);
}
// Change the default widget for fields of type 'foo'.
if
(
isset
(
$info
[
'foo'
]))
{
$info
[
'foo'
][
'default widget'
]
=
'mymodule_widget'
;
}
}
/**
* Define the Field API schema for a field structure.
*
...
...
@@ -186,6 +218,21 @@ function hook_field_schema($field) {
function
hook_field_widget_info
()
{
}
/**
* Perform alterations on Field API widget types.
*
* @param $info
* Array of informations on widget types exposed by hook_field_widget_info()
* implementations.
*/
function
hook_field_widget_info_alter
(
&
$info
)
{
// Add a setting to a widget type.
$info
[
'text_textfield'
][
'settings'
][]
=
array
(
'mymodule_additional_setting'
=>
'default value'
);
// Let a new field type re-use an existing widget.
$info
[
'options_select'
][
'field types'
][]
=
'my_field_type'
;
}
/*
* Define Field API formatter types.
*
...
...
@@ -200,6 +247,21 @@ function hook_field_widget_info() {
function
hook_field_formatter_info
()
{
}
/**
* Perform alterations on Field API formatter types.
*
* @param $info
* Array of informations on widget types exposed by
* hook_field_field_formatter_info() implementations.
*/
function
hook_field_formatter_info_alter
(
&
$info
)
{
// Add a setting to a formatter type.
$info
[
'text_default'
][
'settings'
][]
=
array
(
'mymodule_additional_setting'
=>
'default value'
);
// Let a new field type re-use an existing formatter.
$info
[
'text_default'
][
'field types'
][]
=
'my_field_type'
;
}
/**
* Define custom load behavior for this module's field types.
*
...
...
modules/field/field.info.inc
View file @
5b17c1eb
...
...
@@ -98,6 +98,7 @@ function _field_info_collate_types($reset = FALSE) {
$info
[
'field types'
][
$name
][
'module'
]
=
$module
;
}
}
drupal_alter
(
'field_info'
,
$info
[
'field types'
]);
// Populate widget types.
foreach
(
module_implements
(
'field_widget_info'
)
as
$module
)
{
...
...
@@ -107,6 +108,7 @@ function _field_info_collate_types($reset = FALSE) {
$info
[
'widget types'
][
$name
][
'module'
]
=
$module
;
}
}
drupal_alter
(
'field_widget_info'
,
$info
[
'widget types'
]);
// Populate formatters.
foreach
(
module_implements
(
'field_formatter_info'
)
as
$module
)
{
...
...
@@ -116,6 +118,7 @@ function _field_info_collate_types($reset = FALSE) {
$info
[
'formatter types'
][
$name
][
'module'
]
=
$module
;
}
}
drupal_alter
(
'field_formatter_info'
,
$info
[
'formatter types'
]);
// Populate information about 'fieldable' entities.
foreach
(
module_implements
(
'fieldable_info'
)
as
$module
)
{
...
...
@@ -138,6 +141,7 @@ function _field_info_collate_types($reset = FALSE) {
$info
[
'fieldable types'
][
$name
][
'module'
]
=
$module
;
}
}
drupal_alter
(
'fieldable_info'
,
$info
[
'fieldable types'
]);
cache_set
(
'field_info_types'
,
$info
,
'cache_field'
);
}
...
...
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