Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
field_collection
Commits
78a18ce4
Commit
78a18ce4
authored
Mar 02, 2019
by
Ra Mänd
Browse files
Coding standard fixes.
parent
01e0a57e
Changes
5
Hide whitespace changes
Inline
Side-by-side
field_collection.api.php
View file @
78a18ce4
...
@@ -66,7 +66,8 @@ function hook_field_collection_item_insert(FieldCollectionItemEntity $field_coll
...
@@ -66,7 +66,8 @@ function hook_field_collection_item_insert(FieldCollectionItemEntity $field_coll
/**
/**
* Acts on a field collection item being inserted or updated.
* Acts on a field collection item being inserted or updated.
*
*
* This hook is invoked before the field collection item is saved to the database.
* This hook is invoked before the field collection item is saved to the
* database.
*
*
* @param FieldCollectionItemEntity $field_collection_item
* @param FieldCollectionItemEntity $field_collection_item
* The field collection item that is being inserted or updated.
* The field collection item that is being inserted or updated.
...
@@ -140,7 +141,7 @@ function hook_field_collection_item_view($field_collection_item, $view_mode, $la
...
@@ -140,7 +141,7 @@ function hook_field_collection_item_view($field_collection_item, $view_mode, $la
/**
/**
* Alter the results of entity_view() for field collection items.
* Alter the results of entity_view() for field collection items.
*
*
* This hook is called after the content has been assembled in a structured
* This hook is called after the content has been assembled in a structured
* array and may be used for doing processing which requires that the complete
* array and may be used for doing processing which requires that the complete
* field collection item content structure has been built.
* field collection item content structure has been built.
*
*
...
...
field_collection.diff.inc
View file @
78a18ce4
...
@@ -25,7 +25,7 @@ function field_collection_field_render_revision($item, $context) {
...
@@ -25,7 +25,7 @@ function field_collection_field_render_revision($item, $context) {
$view_mode
=
$context
[
'view_mode'
];
$view_mode
=
$context
[
'view_mode'
];
$entity
=
entity_revision_load
(
$entity_type
,
$item
[
'revision_id'
]);
$entity
=
entity_revision_load
(
$entity_type
,
$item
[
'revision_id'
]);
if
(
empty
(
$entity
))
{
if
(
empty
(
$entity
))
{
return
array
();
return
array
();
}
}
...
@@ -50,7 +50,8 @@ function field_collection_field_render_revision($item, $context) {
...
@@ -50,7 +50,8 @@ function field_collection_field_render_revision($item, $context) {
$result
=
array
();
$result
=
array
();
foreach
(
$instances
as
$instance
)
{
foreach
(
$instances
as
$instance
)
{
// Any view mode is supported in relation to hiding fields, but only if selected.
// Any view mode is supported in relation to hiding fields, but only if
// selected.
if
(
$actual_mode
&&
$instance
[
'display'
][
$actual_mode
][
'type'
]
==
'hidden'
)
{
if
(
$actual_mode
&&
$instance
[
'display'
][
$actual_mode
][
'type'
]
==
'hidden'
)
{
continue
;
continue
;
}
}
...
...
field_collection.entity.inc
View file @
78a18ce4
...
@@ -512,9 +512,11 @@ class FieldCollectionItemEntity extends Entity {
...
@@ -512,9 +512,11 @@ class FieldCollectionItemEntity extends Entity {
if
(
$fields
[
$translatable_field
][
'translatable'
]
==
1
)
{
if
(
$fields
[
$translatable_field
][
'translatable'
]
==
1
)
{
foreach
(
$target_languages
as
$langcode
)
{
foreach
(
$target_languages
as
$langcode
)
{
if
(
isset
(
$this
->
{
$translatable_field
}[
$source_language
]))
{
if
(
isset
(
$this
->
{
$translatable_field
}[
$source_language
]))
{
//Source (translatable_field) is set, therefore continue processing.
// Source (translatable_field) is set, therefore continue
if
(
!
isset
(
$this
->
{
$translatable_field
}[
$langcode
]))
{
// processing.
//Destination (translatable_field) is not set, therefore safe to copy the translation.
if
(
!
isset
(
$this
->
{
$translatable_field
}[
$langcode
]))
{
// Destination (translatable_field) is not set, therefore safe to
// copy the translation.
$this
->
{
$translatable_field
}[
$langcode
]
=
$this
->
{
$translatable_field
}[
$source_language
];
$this
->
{
$translatable_field
}[
$langcode
]
=
$this
->
{
$translatable_field
}[
$source_language
];
}
}
}
}
...
@@ -639,4 +641,5 @@ class FieldCollectionItemEntity extends Entity {
...
@@ -639,4 +641,5 @@ class FieldCollectionItemEntity extends Entity {
public
function
__wakeup
()
{
public
function
__wakeup
()
{
$this
->
setUp
();
$this
->
setUp
();
}
}
}
}
field_collection.migrate.inc
View file @
78a18ce4
...
@@ -83,10 +83,10 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
...
@@ -83,10 +83,10 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
/**
/**
* Import a single field collection item.
* Import a single field collection item.
*
*
* @param $collection
* @param
\stdClass
$collection
* Collection object to build. Pre-filled with any fields mapped in the
* Collection object to build. Pre-filled with any fields mapped in the
* migration.
* migration.
* @param $row
* @param
\stdClass
$row
* Raw source data object - passed through to prepare/complete handlers.
* Raw source data object - passed through to prepare/complete handlers.
*
*
* @return array|bool
* @return array|bool
...
...
field_collection.module
View file @
78a18ce4
...
@@ -184,7 +184,11 @@ function field_collection_item_load($item_id, $reset = FALSE) {
...
@@ -184,7 +184,11 @@ function field_collection_item_load($item_id, $reset = FALSE) {
* Loads a field collection revision.
* Loads a field collection revision.
*
*
* @param $revision_id
* @param $revision_id
* The field collection revision ID.
* The id of the revision to load.
*
* @return
* The entity object, or FALSE if there is no entity with the given revision
* id.
*/
*/
function
field_collection_item_revision_load
(
$revision_id
)
{
function
field_collection_item_revision_load
(
$revision_id
)
{
return
entity_revision_load
(
'field_collection_item'
,
$revision_id
);
return
entity_revision_load
(
'field_collection_item'
,
$revision_id
);
...
@@ -193,6 +197,16 @@ function field_collection_item_revision_load($revision_id) {
...
@@ -193,6 +197,16 @@ function field_collection_item_revision_load($revision_id) {
/**
/**
* Loads field collection items.
* Loads field collection items.
*
*
* @param $ids
* An array of entity IDs, or FALSE to load all entities.
* @param $conditions
* (deprecated) An associative array of conditions on the base table, where
* the keys are the database fields and the values are the values those
* fields must have. Instead, it is preferable to use EntityFieldQuery to
* retrieve a list of entity IDs loadable by this function.
* @param $reset
* Whether to reset the internal cache for the requested entity type.
*
* @return
* @return
* An array of field collection item entities.
* An array of field collection item entities.
*/
*/
...
@@ -299,6 +313,8 @@ function field_collection_menu_alter(&$items) {
...
@@ -299,6 +313,8 @@ function field_collection_menu_alter(&$items) {
/**
/**
* Menu title callback.
* Menu title callback.
*
* return string
*/
*/
function
field_collection_admin_page_title
(
$field_name
)
{
function
field_collection_admin_page_title
(
$field_name
)
{
return
t
(
'Field collection @field_name'
,
array
(
'@field_name'
=>
$field_name
));
return
t
(
'Field collection @field_name'
,
array
(
'@field_name'
=>
$field_name
));
...
@@ -306,6 +322,8 @@ function field_collection_admin_page_title($field_name) {
...
@@ -306,6 +322,8 @@ function field_collection_admin_page_title($field_name) {
/**
/**
* Implements hook_admin_paths().
* Implements hook_admin_paths().
*
* @return array
*/
*/
function
field_collection_admin_paths
()
{
function
field_collection_admin_paths
()
{
if
(
variable_get
(
'node_admin_theme'
))
{
if
(
variable_get
(
'node_admin_theme'
))
{
...
@@ -339,6 +357,7 @@ function field_collection_permission() {
...
@@ -339,6 +357,7 @@ function field_collection_permission() {
* items is determined.
* items is determined.
* @param $account
* @param $account
* The user to check for. Leave it to NULL to check for the global user.
* The user to check for. Leave it to NULL to check for the global user.
*
* @return boolean
* @return boolean
* Whether access is allowed or not.
* Whether access is allowed or not.
*/
*/
...
@@ -2134,15 +2153,15 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
...
@@ -2134,15 +2153,15 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
$field_collection_item
=
null
;
$field_collection_item
=
null
;
// FC is already set on host entity.
// FC is already set on host entity.
if
(
isset
(
$field
[
'und'
][
$delta
][
'entity'
]))
{
if
(
isset
(
$field
[
LANGUAGE_NONE
][
$delta
][
'entity'
]))
{
$field_collection_item
=
$field
[
'und'
][
$delta
][
'entity'
];
$field_collection_item
=
$field
[
LANGUAGE_NONE
][
$delta
][
'entity'
];
}
}
// FC is on host entity, we have FC item_id, but FC is not loaded.
// FC is on host entity, we have FC item_id, but FC is not loaded.
elseif
(
isset
(
$field
[
'und'
][
$delta
][
'value'
]))
{
elseif
(
isset
(
$field
[
LANGUAGE_NONE
][
$delta
][
'value'
]))
{
$field_collection_item
=
field_collection_item_load
(
$field
[
'und'
][
$delta
][
'value'
]);
$field_collection_item
=
field_collection_item_load
(
$field
[
LANGUAGE_NONE
][
$delta
][
'value'
]);
// Zero out field so that we don't just keep accumulating values.
// Zero out field so that we don't just keep accumulating values.
unset
(
$field_collection_item
->
{
$sub_target
}[
'und'
]
);
unset
(
$field_collection_item
->
{
$sub_target
}[
LANGUAGE_NONE
]
);
}
}
// Host entity does not have any attached FCs yet.
// Host entity does not have any attached FCs yet.
...
@@ -2195,7 +2214,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
...
@@ -2195,7 +2214,7 @@ function field_collection_feeds_set_target($source, $entity, $target, $value, $m
// No need to save the field collection here. Just wait until the node is saved.
// No need to save the field collection here. Just wait until the node is saved.
// If we save the FC here we get a huge performance degregation.
// If we save the FC here we get a huge performance degregation.
$field
[
'und'
][
$delta
][
'entity'
]
=
$field_collection_item
;
$field
[
LANGUAGE_NONE
][
$delta
][
'entity'
]
=
$field_collection_item
;
// Break when only hitting the max delta.
// Break when only hitting the max delta.
if
(
$info
[
'cardinality'
]
==
$delta
)
{
if
(
$info
[
'cardinality'
]
==
$delta
)
{
...
@@ -2269,8 +2288,8 @@ function field_collection_file_feeds_set_target($source, $entity, $target, $valu
...
@@ -2269,8 +2288,8 @@ function field_collection_file_feeds_set_target($source, $entity, $target, $valu
watchdog
(
'feeds'
,
check_plain
(
$e
->
getMessage
()));
watchdog
(
'feeds'
,
check_plain
(
$e
->
getMessage
()));
}
}
if
(
$file
)
{
if
(
$file
)
{
$field
[
'und'
][
$i
]
=
(
array
)
$file
;
$field
[
LANGUAGE_NONE
][
$i
]
=
(
array
)
$file
;
$field
[
'und'
][
$i
][
'display'
]
=
1
;
// @todo: Figure out how to properly populate this field.
$field
[
LANGUAGE_NONE
][
$i
][
'display'
]
=
1
;
// @todo: Figure out how to properly populate this field.
if
(
$info
[
'cardinality'
]
==
1
)
{
if
(
$info
[
'cardinality'
]
==
1
)
{
break
;
break
;
}
}
...
@@ -2316,11 +2335,11 @@ function field_collection_feeds_presave(FeedsSource $source, $entity, $item, $en
...
@@ -2316,11 +2335,11 @@ function field_collection_feeds_presave(FeedsSource $source, $entity, $item, $en
}
}
if
(
isset
(
$entity
->
{
$fc_name
}))
{
if
(
isset
(
$entity
->
{
$fc_name
}))
{
foreach
(
$entity
->
{
$fc_name
}[
'und'
]
as
$delta
=>
$fc_unloaded
)
{
foreach
(
$entity
->
{
$fc_name
}[
LANGUAGE_NONE
]
as
$delta
=>
$fc_unloaded
)
{
// If an FC is not loaded, we don't want it. Unset it so it won't save.
// If an FC is not loaded, we don't want it. Unset it so it won't save.
if
(
!
isset
(
$entity
->
{
$fc_name
}[
'und'
][
$delta
][
'entity'
]))
{
if
(
!
isset
(
$entity
->
{
$fc_name
}[
LANGUAGE_NONE
][
$delta
][
'entity'
]))
{
unset
(
$entity
->
{
$fc_name
}[
'und'
][
$delta
]);
unset
(
$entity
->
{
$fc_name
}[
LANGUAGE_NONE
][
$delta
]);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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