Commit d5ee6a5e authored by lkmorlan's avatar lkmorlan Committed by Renato Gonçalves H
Browse files

Issue #2739797 by harivenuv, Liam Morland, RenatoG, Chris Matthews, jmuzz:...

Issue #2739797 by harivenuv, Liam Morland, RenatoG, Chris Matthews, jmuzz: This module is not following drupal coding standard
parent 71b9e418
...@@ -132,6 +132,10 @@ function hook_field_collection_item_archive(FieldCollectionItemEntity $field_col ...@@ -132,6 +132,10 @@ function hook_field_collection_item_archive(FieldCollectionItemEntity $field_col
/** /**
* Act on a field collection item that is being assembled before rendering. * Act on a field collection item that is being assembled before rendering.
* *
* The module may add elements to $field_collection_item->content prior to
* rendering. The structure of $field_collection_item->content is a renderable
* array as expected by drupal_render().
*
* @param $field_collection_item * @param $field_collection_item
* The field collection item entity. * The field collection item entity.
* @param $view_mode * @param $view_mode
...@@ -139,10 +143,6 @@ function hook_field_collection_item_archive(FieldCollectionItemEntity $field_col ...@@ -139,10 +143,6 @@ function hook_field_collection_item_archive(FieldCollectionItemEntity $field_col
* @param $langcode * @param $langcode
* The language code used for rendering. * The language code used for rendering.
* *
* The module may add elements to $field_collection_item->content prior to
* rendering. The structure of $field_collection_item->content is a renderable
* array as expected by drupal_render().
*
* @see hook_entity_prepare_view() * @see hook_entity_prepare_view()
* @see hook_entity_view() * @see hook_entity_view()
*/ */
...@@ -191,7 +191,7 @@ function hook_field_collection_item_view_alter($build) { ...@@ -191,7 +191,7 @@ function hook_field_collection_item_view_alter($build) {
* @param $field * @param $field
* The field information about the item. * The field information about the item.
* *
* @return $label * @return string
* A string to represent the label for this item type. * A string to represent the label for this item type.
*/ */
function hook_field_collection_item_label($item, $host, $field) { function hook_field_collection_item_label($item, $host, $field) {
...@@ -206,7 +206,6 @@ function hook_field_collection_item_label($item, $host, $field) { ...@@ -206,7 +206,6 @@ function hook_field_collection_item_label($item, $host, $field) {
} }
} }
/** /**
* @} * @}
*/ */
...@@ -22,14 +22,14 @@ class FieldCollectionItemEntity extends Entity { ...@@ -22,14 +22,14 @@ class FieldCollectionItemEntity extends Entity {
/** /**
* The host entity ID. * The host entity ID.
* *
* @var integer * @var int
*/ */
protected $hostEntityId; protected $hostEntityId;
/** /**
* The host entity revision ID if this is not the default revision. * The host entity revision ID if this is not the default revision.
* *
* @var integer * @var int
*/ */
protected $hostEntityRevisionId; protected $hostEntityRevisionId;
...@@ -50,14 +50,14 @@ class FieldCollectionItemEntity extends Entity { ...@@ -50,14 +50,14 @@ class FieldCollectionItemEntity extends Entity {
/** /**
* Entity ID. * Entity ID.
* *
* @var integer * @var int
*/ */
public $item_id; public $item_id;
/** /**
* Field Collection revision ID. * Field Collection revision ID.
* *
* @var integer * @var int
*/ */
public $revision_id; public $revision_id;
...@@ -95,7 +95,7 @@ class FieldCollectionItemEntity extends Entity { ...@@ -95,7 +95,7 @@ class FieldCollectionItemEntity extends Entity {
// FIXME: Remove when #1264440 is fixed and the required PHP version is // FIXME: Remove when #1264440 is fixed and the required PHP version is
// properly identified and documented in the module documentation. // properly identified and documented in the module documentation.
if (isset($this->field_name)) { if (isset($this->field_name)) {
// Ok, we have the field name property, we can proceed and check the field's type // Ok, we have the field name property, we can proceed and check the field's type.
$field_info = $this->fieldInfo(); $field_info = $this->fieldInfo();
if (!$field_info || $field_info['type'] != 'field_collection') { if (!$field_info || $field_info['type'] != 'field_collection') {
throw new Exception("Invalid field name given: {$this->field_name} is not a Field Collection field."); throw new Exception("Invalid field name given: {$this->field_name} is not a Field Collection field.");
......
...@@ -5,8 +5,14 @@ ...@@ -5,8 +5,14 @@
* Provides entity property info for field collection items. * Provides entity property info for field collection items.
*/ */
/**
*
*/
class FieldCollectionItemMetadataController extends EntityDefaultMetadataController { class FieldCollectionItemMetadataController extends EntityDefaultMetadataController {
/**
*
*/
public function entityPropertyInfo() { public function entityPropertyInfo() {
$info = parent::entityPropertyInfo(); $info = parent::entityPropertyInfo();
$properties = &$info['field_collection_item']['properties']; $properties = &$info['field_collection_item']['properties'];
......
...@@ -68,7 +68,7 @@ function field_collection_schema() { ...@@ -68,7 +68,7 @@ function field_collection_schema() {
$schema['cache_entity_field_collection_item'] = drupal_get_schema_unprocessed('system', 'cache'); $schema['cache_entity_field_collection_item'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_entity_field_collection_item']['description'] = 'Cache table used to store field_collection_item entity records.'; $schema['cache_entity_field_collection_item']['description'] = 'Cache table used to store field_collection_item entity records.';
} }
return $schema; return $schema;
} }
...@@ -293,10 +293,10 @@ function field_collection_update_7004() { ...@@ -293,10 +293,10 @@ function field_collection_update_7004() {
/** /**
* Force the creation of the table cache_entity_field_collection_item. * Force the creation of the table cache_entity_field_collection_item.
* *
* entity_update_7003 will attempt to install entitycache tables for existing * Update entity_update_7003() will attempt to install entitycache tables for
* modules, but it uses module_list() to get the list of available modules, * existing modules, but it uses module_list() to get the list of available
* which, when called from a database update, may not return field_collection * modules, which, when called from a database update, may not return
* since drupal is bootstrapped at a lower level. * field_collection since drupal is bootstrapped at a lower level.
*/ */
function field_collection_update_7005() { function field_collection_update_7005() {
if (module_exists('entitycache')) { if (module_exists('entitycache')) {
...@@ -500,8 +500,6 @@ function field_collection_update_7009(&$sandbox) { ...@@ -500,8 +500,6 @@ function field_collection_update_7009(&$sandbox) {
} }
} }
foreach ($modern_revisions as $each_modern_revision) { foreach ($modern_revisions as $each_modern_revision) {
$new_revision_id = _field_collection_update_7009_new_revision($field_collection_item_id, $each_modern_revision, $sandbox['inner_fields'], $sandbox['field_name']); $new_revision_id = _field_collection_update_7009_new_revision($field_collection_item_id, $each_modern_revision, $sandbox['inner_fields'], $sandbox['field_name']);
...@@ -557,6 +555,9 @@ function field_collection_update_7009(&$sandbox) { ...@@ -557,6 +555,9 @@ function field_collection_update_7009(&$sandbox) {
} }
} }
/**
*
*/
function _field_collection_update_7009_new_revision($field_collection_item_id, $row_to_replace, $inner_fields, $field_name) { function _field_collection_update_7009_new_revision($field_collection_item_id, $row_to_replace, $inner_fields, $field_name) {
// Add to field_collection_item_revision table. // Add to field_collection_item_revision table.
$new_revision_id = db_insert('field_collection_item_revision') $new_revision_id = db_insert('field_collection_item_revision')
...@@ -566,6 +567,9 @@ function _field_collection_update_7009_new_revision($field_collection_item_id, $ ...@@ -566,6 +567,9 @@ function _field_collection_update_7009_new_revision($field_collection_item_id, $
return $new_revision_id; return $new_revision_id;
} }
/**
*
*/
function _field_collection_update_7009_update_data($new_revision, $old_revision) { function _field_collection_update_7009_update_data($new_revision, $old_revision) {
// Update the current field collection item. // Update the current field collection item.
db_update('field_collection_item') db_update('field_collection_item')
......
...@@ -41,6 +41,9 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity { ...@@ -41,6 +41,9 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
*/ */
protected $hostEntityType; protected $hostEntityType;
/**
*
*/
public static function getKeySchema() { public static function getKeySchema() {
return array( return array(
'item_id' => array( 'item_id' => array(
...@@ -83,10 +86,10 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity { ...@@ -83,10 +86,10 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
/** /**
* Import a single field collection item. * Import a single field collection item.
* *
* @param \stdClass $collection * @param object $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 \stdClass $row * @param object $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
......
...@@ -18,6 +18,7 @@ function field_collection_item_page_view($field_collection_item) { ...@@ -18,6 +18,7 @@ function field_collection_item_page_view($field_collection_item) {
/** /**
* Form for editing a field collection item. * Form for editing a field collection item.
*
* @todo implement hook_forms(). * @todo implement hook_forms().
*/ */
function field_collection_item_form($form, &$form_state, $field_collection_item) { function field_collection_item_form($form, &$form_state, $field_collection_item) {
......
<?php <?php
/**
* @file
*/
/** /**
* Implements hook_pathauto(). * Implements hook_pathauto().
*/ */
...@@ -14,7 +18,6 @@ function field_collection_pathauto($op) { ...@@ -14,7 +18,6 @@ function field_collection_pathauto($op) {
// @todo Implement bulk update: // @todo Implement bulk update:
// $settings['batch_update_callback'] = 'field_collection_pathauto_bulk_update_batch_process'; // $settings['batch_update_callback'] = 'field_collection_pathauto_bulk_update_batch_process';
// $settings['batch_file'] = drupal_get_path('module', 'field_collection') . '/field_collection.pathauto.inc'; // $settings['batch_file'] = drupal_get_path('module', 'field_collection') . '/field_collection.pathauto.inc';
$settings['patternitems'] = array(); $settings['patternitems'] = array();
$instances = field_info_instances(); $instances = field_info_instances();
foreach ($instances as $entity_type => $type_bundles) { foreach ($instances as $entity_type => $type_bundles) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* field_collections tests. * Tests for field_collections.
*/ */
/** /**
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
*/ */
class FieldCollectionBasicTestCase extends DrupalWebTestCase { class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field collection', 'name' => 'Field collection',
...@@ -18,7 +21,10 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -18,7 +21,10 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
); );
} }
function setUp() { /**
*
*/
public function setUp() {
parent::setUp('field_collection', 'entity_crud_hook_test'); parent::setUp('field_collection', 'entity_crud_hook_test');
// Create a field_collection field to use for the tests. // Create a field_collection field to use for the tests.
...@@ -63,6 +69,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -63,6 +69,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
* Message to display. * Message to display.
* @param $group * @param $group
* The group this message belongs to, defaults to 'Other'. * The group this message belongs to, defaults to 'Other'.
*
* @return * @return
* TRUE on pass, FALSE on fail. * TRUE on pass, FALSE on fail.
*/ */
...@@ -124,7 +131,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -124,7 +131,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/** /**
* Tests CRUD. * Tests CRUD.
*/ */
function testCRUD() { public function testCRUD() {
list ($node, $entity) = $this->createNodeWithFieldCollection(); list ($node, $entity) = $this->createNodeWithFieldCollection();
$node = node_load($node->nid, NULL, TRUE); $node = node_load($node->nid, NULL, TRUE);
$this->assertEqual($entity->item_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['value'], 'A field_collection has been successfully created and referenced.'); $this->assertEqual($entity->item_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['value'], 'A field_collection has been successfully created and referenced.');
...@@ -304,7 +311,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -304,7 +311,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/** /**
* Make sure the basic UI and access checks are working. * Make sure the basic UI and access checks are working.
*/ */
function testBasicUI() { public function testBasicUI() {
// Add a field to the collection. // Add a field to the collection.
$field = array( $field = array(
'field_name' => 'field_text', 'field_name' => 'field_text',
...@@ -432,6 +439,9 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase { ...@@ -432,6 +439,9 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
*/ */
class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field collection Rules integration', 'name' => 'Field collection Rules integration',
...@@ -441,11 +451,17 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -441,11 +451,17 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
); );
} }
function setUp() { /**
*
*/
public function setUp() {
parent::setUp(array('field_collection', 'rules')); parent::setUp(array('field_collection', 'rules'));
variable_set('rules_debug_log', 1); variable_set('rules_debug_log', 1);
} }
/**
*
*/
protected function createFields($cardinality = 4) { protected function createFields($cardinality = 4) {
// Create a field_collection field to use for the tests. // Create a field_collection field to use for the tests.
$this->field_name = 'field_test_collection'; $this->field_name = 'field_test_collection';
...@@ -491,7 +507,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -491,7 +507,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/** /**
* Test creation field collection items. * Test creation field collection items.
*/ */
function testCreation() { public function testCreation() {
$this->createFields(); $this->createFields();
$node = $this->drupalCreateNode(array('type' => 'article')); $node = $this->drupalCreateNode(array('type' => 'article'));
...@@ -522,7 +538,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -522,7 +538,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/** /**
* Test using field collection items via the host while they are being created. * Test using field collection items via the host while they are being created.
*/ */
function testUsageDuringCreation() { public function testUsageDuringCreation() {
// Test using a single-cardinality field collection. // Test using a single-cardinality field collection.
$this->createFields(1); $this->createFields(1);
...@@ -530,7 +546,6 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -530,7 +546,6 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name)); $entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
$entity->setHostEntity('node', $node); $entity->setHostEntity('node', $node);
// Now the field collection is linked to the host, but not yet saved. // Now the field collection is linked to the host, but not yet saved.
// Test using the wrapper on it. // Test using the wrapper on it.
$wrapper = entity_metadata_wrapper('node', $node); $wrapper = entity_metadata_wrapper('node', $node);
$wrapper->get($this->field_name)->field_text->set('foo'); $wrapper->get($this->field_name)->field_text->set('foo');
...@@ -544,6 +559,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -544,6 +559,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
$this->assertTrue(!empty($entity->item_id) && !empty($entity->revision_id), 'Field collection item has been saved by Rules and the host entity.'); $this->assertTrue(!empty($entity->item_id) && !empty($entity->revision_id), 'Field collection item has been saved by Rules and the host entity.');
RulesLog::logger()->checkLog(); RulesLog::logger()->checkLog();
} }
} }
/** /**
...@@ -551,6 +567,9 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase { ...@@ -551,6 +567,9 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
*/ */
class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase { class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field collection content translation', 'name' => 'Field collection content translation',
...@@ -560,6 +579,9 @@ class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase { ...@@ -560,6 +579,9 @@ class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
); );
} }
/**
*
*/
public function setUp() { public function setUp() {
parent::setUp(array('field_collection', 'translation')); parent::setUp(array('field_collection', 'translation'));
// Create a field_collection field to use for the tests. // Create a field_collection field to use for the tests.
...@@ -659,6 +681,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -659,6 +681,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
const UNTRANS_FIELD_DE_MOD = 'Untranslatable DE Mod'; const UNTRANS_FIELD_DE_MOD = 'Untranslatable DE Mod';
const NUM_VALUES = 4; const NUM_VALUES = 4;
/**
*
*/
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field collection entity translation', 'name' => 'Field collection entity translation',
...@@ -671,7 +696,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -671,7 +696,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
/** /**
* Login the given user only if she has not changed. * Login the given user only if she has not changed.
*/ */
function login($user) { public function login($user) {
if (!isset($this->current_user) || $this->current_user->uid != $user->uid) { if (!isset($this->current_user) || $this->current_user->uid != $user->uid) {
$this->current_user = $user; $this->current_user = $user;
$this->drupalLogin($user); $this->drupalLogin($user);
...@@ -684,7 +709,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -684,7 +709,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param $permissions * @param $permissions
* Additional permissions for administrative user. * Additional permissions for administrative user.
*/ */
function getAdminUser(array $permissions = array()) { public function getAdminUser(array $permissions = array()) {
if (!isset($this->admin_user)) { if (!isset($this->admin_user)) {
$this->admin_user = $this->drupalCreateUser(array_merge(array( $this->admin_user = $this->drupalCreateUser(array_merge(array(
'bypass node access', 'bypass node access',
...@@ -706,7 +731,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -706,7 +731,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param $permissions * @param $permissions
* Additional permissions for administrative user. * Additional permissions for administrative user.
*/ */
function getTranslatorUser(array $permissions = array()) { public function getTranslatorUser(array $permissions = array()) {
if (!isset($this->translator_user)) { if (!isset($this->translator_user)) {
$this->translator_user = $this->drupalCreateUser(array_merge(array( $this->translator_user = $this->drupalCreateUser(array_merge(array(
'create page content', 'create page content',
...@@ -725,7 +750,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -725,7 +750,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param string $langcode * @param string $langcode
* The language code to check. * The language code to check.
*/ */
function addLanguage($langcode) { public function addLanguage($langcode) {
// Check to make sure that language has not already been installed. // Check to make sure that language has not already been installed.
$this->drupalGet('admin/config/regional/language'); $this->drupalGet('admin/config/regional/language');
...@@ -756,6 +781,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -756,6 +781,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
} }
} }
/**
*
*/
public function setUp() { public function setUp() {
parent::setUp(array('field_collection', 'entity_translation')); parent::setUp(array('field_collection', 'entity_translation'));
$language_none = LANGUAGE_NONE; $language_none = LANGUAGE_NONE;
...@@ -853,10 +881,10 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -853,10 +881,10 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
/** /**
* Creates a basic page with a value in the field collection. * Creates a basic page with a value in the field collection.
* *
* @param integer $num_values * @param int $num_values
* The number of values to include in the field collection. * The number of values to include in the field collection.
* @param string $langcode * @param string $langcode
* Language for the node. * Language for the node.
*/ */
protected function createPage($num_values, $langcode = 'en') { protected function createPage($num_values, $langcode = 'en') {
// Check if num_values is greater than the field cardinality. // Check if num_values is greater than the field cardinality.
...@@ -904,7 +932,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -904,7 +932,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
$language_none = LANGUAGE_NONE; $language_none = LANGUAGE_NONE;
$edit = array(); $edit = array();
$this->drupalGet('node/' . $node->nid . '/edit/add/' . $source_langcode . '/' .$langcode); $this->drupalGet('node/' . $node->nid . '/edit/add/' . $source_langcode . '/' . $langcode);
// Get the field collection in the original language. // Get the field collection in the original language.
$fc_values = $node->{$this->field_name}[$source_langcode]; $fc_values = $node->{$this->field_name}[$source_langcode];
...@@ -1127,7 +1155,8 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase { ...@@ -1127,7 +1155,8 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* *
* @param mixed $node * @param mixed $node
* @param string $langcode * @param string $langcode
* @param integer $delta * @param int $delta
*
* @return array * @return array
*/ */
protected function getFieldValues($node, $langcode, $delta) { protected function getFieldValues($node, $langcode, $delta) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Provides host entity tokens for field_collection.module * Provides host entity tokens for field_collection.module.
*/ */