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
/**
* 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
* The field collection item entity.
* @param $view_mode
......@@ -139,10 +143,6 @@ function hook_field_collection_item_archive(FieldCollectionItemEntity $field_col
* @param $langcode
* 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_view()
*/
......@@ -191,7 +191,7 @@ function hook_field_collection_item_view_alter($build) {
* @param $field
* The field information about the item.
*
* @return $label
* @return string
* A string to represent the label for this item type.
*/
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 {
/**
* The host entity ID.
*
* @var integer
* @var int
*/
protected $hostEntityId;
/**
* The host entity revision ID if this is not the default revision.
*
* @var integer
* @var int
*/
protected $hostEntityRevisionId;
......@@ -50,14 +50,14 @@ class FieldCollectionItemEntity extends Entity {
/**
* Entity ID.
*
* @var integer
* @var int
*/
public $item_id;
/**
* Field Collection revision ID.
*
* @var integer
* @var int
*/
public $revision_id;
......@@ -95,7 +95,7 @@ class FieldCollectionItemEntity extends Entity {
// FIXME: Remove when #1264440 is fixed and the required PHP version is
// properly identified and documented in the module documentation.
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();
if (!$field_info || $field_info['type'] != 'field_collection') {
throw new Exception("Invalid field name given: {$this->field_name} is not a Field Collection field.");
......
......@@ -5,8 +5,14 @@
* Provides entity property info for field collection items.
*/
/**
*
*/
class FieldCollectionItemMetadataController extends EntityDefaultMetadataController {
/**
*
*/
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$properties = &$info['field_collection_item']['properties'];
......
......@@ -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']['description'] = 'Cache table used to store field_collection_item entity records.';
}
return $schema;
}
......@@ -293,10 +293,10 @@ function field_collection_update_7004() {
/**
* Force the creation of the table cache_entity_field_collection_item.
*
* entity_update_7003 will attempt to install entitycache tables for existing
* modules, but it uses module_list() to get the list of available modules,
* which, when called from a database update, may not return field_collection
* since drupal is bootstrapped at a lower level.
* Update entity_update_7003() will attempt to install entitycache tables for
* existing modules, but it uses module_list() to get the list of available
* modules, which, when called from a database update, may not return
* field_collection since drupal is bootstrapped at a lower level.
*/
function field_collection_update_7005() {
if (module_exists('entitycache')) {
......@@ -500,8 +500,6 @@ function field_collection_update_7009(&$sandbox) {
}
}
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']);
......@@ -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) {
// Add to field_collection_item_revision table.
$new_revision_id = db_insert('field_collection_item_revision')
......@@ -566,6 +567,9 @@ function _field_collection_update_7009_new_revision($field_collection_item_id, $
return $new_revision_id;
}
/**
*
*/
function _field_collection_update_7009_update_data($new_revision, $old_revision) {
// Update the current field collection item.
db_update('field_collection_item')
......
......@@ -41,6 +41,9 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
*/
protected $hostEntityType;
/**
*
*/
public static function getKeySchema() {
return array(
'item_id' => array(
......@@ -83,10 +86,10 @@ class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
/**
* Import a single field collection item.
*
* @param \stdClass $collection
* @param object $collection
* Collection object to build. Pre-filled with any fields mapped in the
* migration.
* @param \stdClass $row
* @param object $row
* Raw source data object - passed through to prepare/complete handlers.
*
* @return array|bool
......
......@@ -18,6 +18,7 @@ function field_collection_item_page_view($field_collection_item) {
/**
* Form for editing a field collection item.
*
* @todo implement hook_forms().
*/
function field_collection_item_form($form, &$form_state, $field_collection_item) {
......
<?php
/**
* @file
*/
/**
* Implements hook_pathauto().
*/
......@@ -14,7 +18,6 @@ function field_collection_pathauto($op) {
// @todo Implement bulk update:
// $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['patternitems'] = array();
$instances = field_info_instances();
foreach ($instances as $entity_type => $type_bundles) {
......
......@@ -2,7 +2,7 @@
/**
* @file
* field_collections tests.
* Tests for field_collections.
*/
/**
......@@ -10,6 +10,9 @@
*/
class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field collection',
......@@ -18,7 +21,10 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
);
}
function setUp() {
/**
*
*/
public function setUp() {
parent::setUp('field_collection', 'entity_crud_hook_test');
// Create a field_collection field to use for the tests.
......@@ -63,6 +69,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
* Message to display.
* @param $group
* The group this message belongs to, defaults to 'Other'.
*
* @return
* TRUE on pass, FALSE on fail.
*/
......@@ -124,7 +131,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/**
* Tests CRUD.
*/
function testCRUD() {
public function testCRUD() {
list ($node, $entity) = $this->createNodeWithFieldCollection();
$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.');
......@@ -304,7 +311,7 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
/**
* Make sure the basic UI and access checks are working.
*/
function testBasicUI() {
public function testBasicUI() {
// Add a field to the collection.
$field = array(
'field_name' => 'field_text',
......@@ -432,6 +439,9 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
*/
class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field collection Rules integration',
......@@ -441,11 +451,17 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
);
}
function setUp() {
/**
*
*/
public function setUp() {
parent::setUp(array('field_collection', 'rules'));
variable_set('rules_debug_log', 1);
}
/**
*
*/
protected function createFields($cardinality = 4) {
// Create a field_collection field to use for the tests.
$this->field_name = 'field_test_collection';
......@@ -491,7 +507,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/**
* Test creation field collection items.
*/
function testCreation() {
public function testCreation() {
$this->createFields();
$node = $this->drupalCreateNode(array('type' => 'article'));
......@@ -522,7 +538,7 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
/**
* 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.
$this->createFields(1);
......@@ -530,7 +546,6 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
$entity->setHostEntity('node', $node);
// Now the field collection is linked to the host, but not yet saved.
// Test using the wrapper on it.
$wrapper = entity_metadata_wrapper('node', $node);
$wrapper->get($this->field_name)->field_text->set('foo');
......@@ -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.');
RulesLog::logger()->checkLog();
}
}
/**
......@@ -551,6 +567,9 @@ class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
*/
class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field collection content translation',
......@@ -560,6 +579,9 @@ class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
);
}
/**
*
*/
public function setUp() {
parent::setUp(array('field_collection', 'translation'));
// Create a field_collection field to use for the tests.
......@@ -659,6 +681,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
const UNTRANS_FIELD_DE_MOD = 'Untranslatable DE Mod';
const NUM_VALUES = 4;
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field collection entity translation',
......@@ -671,7 +696,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
/**
* 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) {
$this->current_user = $user;
$this->drupalLogin($user);
......@@ -684,7 +709,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param $permissions
* Additional permissions for administrative user.
*/
function getAdminUser(array $permissions = array()) {
public function getAdminUser(array $permissions = array()) {
if (!isset($this->admin_user)) {
$this->admin_user = $this->drupalCreateUser(array_merge(array(
'bypass node access',
......@@ -706,7 +731,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param $permissions
* Additional permissions for administrative user.
*/
function getTranslatorUser(array $permissions = array()) {
public function getTranslatorUser(array $permissions = array()) {
if (!isset($this->translator_user)) {
$this->translator_user = $this->drupalCreateUser(array_merge(array(
'create page content',
......@@ -725,7 +750,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
* @param string $langcode
* The language code to check.
*/
function addLanguage($langcode) {
public function addLanguage($langcode) {
// Check to make sure that language has not already been installed.
$this->drupalGet('admin/config/regional/language');
......@@ -756,6 +781,9 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
}
}
/**
*
*/
public function setUp() {
parent::setUp(array('field_collection', 'entity_translation'));
$language_none = LANGUAGE_NONE;
......@@ -853,10 +881,10 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
/**
* Creates a basic page with a value in the field collection.
*
* @param integer $num_values
* The number of values to include in the field collection.
* @param string $langcode
* Language for the node.
* @param int $num_values
* The number of values to include in the field collection.
* @param string $langcode
* Language for the node.
*/
protected function createPage($num_values, $langcode = 'en') {
// Check if num_values is greater than the field cardinality.
......@@ -904,7 +932,7 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
$language_none = LANGUAGE_NONE;
$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.
$fc_values = $node->{$this->field_name}[$source_langcode];
......@@ -1127,7 +1155,8 @@ class FieldCollectionEntityTranslationTestCase extends DrupalWebTestCase {
*
* @param mixed $node
* @param string $langcode
* @param integer $delta
* @param int $delta
*
* @return array
*/
protected function getFieldValues($node, $langcode, $delta) {
......
......@@ -2,7 +2,7 @@
/**
* @file
* Provides host entity tokens for field_collection.module
* Provides host entity tokens for field_collection.module.
*/
/**
......
......@@ -17,7 +17,7 @@ class field_collection_handler_relationship extends views_handler_relationship {
/**
* Add a delta selector for multiple fields.
*/
function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$field = field_info_field($this->definition['field_name']);
......@@ -40,7 +40,10 @@ class field_collection_handler_relationship extends views_handler_relationship {
}
}
function ensure_my_table() {
/**
*
*/
public function ensure_my_table() {
$field = field_info_field($this->definition['field_name']);
if (!isset($this->table_alias)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment