diff --git a/lib/Drupal/views/Plugin/views/entity_controller/DefaultEntityController.php b/lib/Drupal/views/Plugin/views/entity_controller/DefaultEntityController.php index 520319d..3af8dda 100644 --- a/lib/Drupal/views/Plugin/views/entity_controller/DefaultEntityController.php +++ b/lib/Drupal/views/Plugin/views/entity_controller/DefaultEntityController.php @@ -8,6 +8,8 @@ namespace Drupal\views\Plugin\views\entity_controller; /** + * @todo + * * @Plugin( * id = "default", */ diff --git a/lib/Drupal/views/Plugin/views/entity_controller/EntityControllerPluginBase.php b/lib/Drupal/views/Plugin/views/entity_controller/EntityControllerPluginBase.php index 20de4dd..9ee9b25 100644 --- a/lib/Drupal/views/Plugin/views/entity_controller/EntityControllerPluginBase.php +++ b/lib/Drupal/views/Plugin/views/entity_controller/EntityControllerPluginBase.php @@ -9,11 +9,11 @@ namespace Drupal\views\Plugin\views\entity_controller; use Drupal\Component\Plugin\PluginBase; - /** - * Generic entity views controller which utilities the entity property api. + * Defines a generic entity views controller that uses the entity property API. */ class EntityControllerPluginBase extends PluginBase { + /** * @todo */ @@ -29,6 +29,16 @@ class EntityControllerPluginBase extends PluginBase { */ protected $relationships; + /** + * Constructs a new entity controller object. + * + * @param array $configuration + * @todo + * @param string $plugin_id + * @todo + * @param string $entity_type + * @todo + */ public function __construct(array $configuration, $plugin_id, $entity_type) { $this->configuration = $configuration; $this->plugin_id = $plugin_id; @@ -39,6 +49,9 @@ class EntityControllerPluginBase extends PluginBase { /** * Defines the result for hook_views_data(). + * + * @return array + * @todo */ public function viewsData() { $data = array(); @@ -71,8 +84,10 @@ class EntityControllerPluginBase extends PluginBase { } /** - * Try to come up with some views fields with the help of the schema and - * the entity property information. + * Identifies views fields based on the schema and entity property data. + * + * @return array + * @todo */ protected function schemaFields() { $schema = drupal_get_schema($this->entity_info['base table']); @@ -95,8 +110,17 @@ class EntityControllerPluginBase extends PluginBase { } /** - * Comes up with views information based on the given schema and property - * info. + * Determines views information from the schema and property information. + * + * @param string $property_name + * @todo + * @param array $schema_field_info + * @todo + * @param array $property_info + * @todo + * + * @return array + * @todo */ protected function mapFromSchemaInfo($property_name, $schema_field_info, $property_info) { $type = isset($property_info['type']) ? $property_info['type'] : 'text'; @@ -120,10 +144,18 @@ class EntityControllerPluginBase extends PluginBase { $label_lowercase = drupal_strtolower($this->entity_info['label'][0]) . drupal_substr($this->entity_info['label'], 1); $property_label_lowercase = drupal_strtolower($property_info['label'][0]) . drupal_substr($property_info['label'], 1); - // We name the field of the first reverse-relationship just with the - // base table to be backward compatible, for subsequents relationships we - // append the views field name in order to get a unique name. - $name = !isset($this->relationships[$info['base table']][$this->entity_info['base table']]) ? $this->entity_info['base table'] : $this->entity_info['base table'] . '_' . $views_field_name; + // The field of the first reverse relationship is named from the base + // table for backwards compatibility. + if (!isset($this->relationships[$info['base table']][$this->entity_info['base table']])){ + $name = $this->entity_info['base table']; + } + // For subsequent relationships, append the views field name to get a + // unique name. + else { + $name = $this->entity_info['base table'] . '_' . $views_field_name; + } + + // @todo Comment here. $this->relationships[$info['base table']][$name] = array( 'title' => $this->entity_info['label'], 'help' => t("Associated @label via the @label's @property.", array('@label' => $label_lowercase, '@property' => $property_label_lowercase)), @@ -136,6 +168,7 @@ class EntityControllerPluginBase extends PluginBase { ), ); + // @todo Comment here. $return['relationship'] = array( 'label' => drupal_ucfirst($info['label']), 'handler' => $this->getRelationshipHandlerClass($type, $this->entity_type), @@ -144,9 +177,9 @@ class EntityControllerPluginBase extends PluginBase { 'relationship field' => $views_field_name, ); - // Add in direct field/filters/sorts for the id itself too. + // Add in direct field/filters/sorts for the ID itself as well. $type = isset($info['entity keys']['name']) ? 'token' : 'integer'; - // Append the views-field-name to the title if it is different to the + // Append the views field name to the title if it is different from the // property name. if ($property_name != $views_field_name) { $description['title'] .= ' ' . $views_field_name; @@ -274,7 +307,7 @@ class EntityControllerPluginBase extends PluginBase { $return['filter']['options callback'] = array('EntityDefaultViewsController', 'optionsListCallback'); $return['filter']['options arguments'] = array($this->type, $property_name, 'view'); } - // @todo: This class_exists is needed until views 3.2. + // @todo This class_exists is needed until views 3.2. if (isset($return['field']) && !empty($property_info['options list']) && class_exists('views_handler_field_machine_name')) { $return['field']['handler'] = 'views_handler_field_machine_name'; $return['field']['options callback'] = array('EntityDefaultViewsController', 'optionsListCallback'); @@ -308,6 +341,4 @@ class EntityControllerPluginBase extends PluginBase { return 'views_handler_relationship'; } - - }