diff --git a/includes/handlers.inc b/includes/handlers.inc index e68d5e584eac2ae36b9d3c416fd935101f9802cb..b01d064fb43cde10961b8fddaa1540bacb1c463f 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -20,9 +20,7 @@ function _views_create_plugin($type, $definition) { $instance->is_plugin = TRUE; $instance->plugin_type = $type; - $instance->plugin_name = $definition['id']; - - $instance->set_definition($definition); + $instance->setDefinition($definition); // Let the handler have something like a constructor. $instance->construct(); @@ -38,9 +36,9 @@ function _views_create_handler($type, $definition) { $instance = $manager->createInstance($definition['id']); $instance->is_handler = TRUE; - $instance->handler_type = $type; + $instance->plugin_type = $type; - $instance->set_definition($definition); + $instance->setDefinition($definition); // let the handler have something like a constructor. $instance->construct(); diff --git a/lib/Drupal/views/Plugin/views/Handler.php b/lib/Drupal/views/Plugin/views/Handler.php index 6d38d7f17ef8f701017a5eb8cebe279a3b94ba4f..6abddef36c21e0d2a7434102d41b418d0aa1f1e2 100644 --- a/lib/Drupal/views/Plugin/views/Handler.php +++ b/lib/Drupal/views/Plugin/views/Handler.php @@ -35,9 +35,9 @@ function init(&$view, &$options) { } $types = View::views_object_types(); - $plural = $this->handler_type; - if (isset($types[$this->handler_type]['plural'])) { - $plural = $types[$this->handler_type]['plural']; + $plural = $this->plugin_type; + if (isset($types[$this->plugin_type]['plural'])) { + $plural = $types[$this->plugin_type]['plural']; } if ($this->view->display_handler->is_defaulted($plural)) { $display_id = 'default'; @@ -45,7 +45,7 @@ function init(&$view, &$options) { $this->localization_keys = array( $display_id, - $this->handler_type, + $this->plugin_type, $options['table'], $options['id'] ); diff --git a/lib/Drupal/views/Plugin/views/Plugin.php b/lib/Drupal/views/Plugin/views/Plugin.php index 44b7fb495df831db4501d709937265e2cee4dace..4aeb3f0803915af6e889d4d3f9ea8676331239b2 100644 --- a/lib/Drupal/views/Plugin/views/Plugin.php +++ b/lib/Drupal/views/Plugin/views/Plugin.php @@ -11,10 +11,6 @@ use Drupal\Component\Plugin\PluginBase; abstract class Plugin extends PluginBase { - public function __construct(array $configuration, $id) { - $this->configuration = $configuration; - $this->id = $id; - } /** * Except for displays, options for the object will be held here. @@ -35,6 +31,19 @@ public function __construct(array $configuration, $id) { */ var $definition; + /** + * The plugin type of this plugin, for example style or query. + */ + var $plugin_type = NULL; + + /** + * Constructs a Plugin object. + */ + public function __construct(array $configuration, $plugin_id) { + $this->configuration = $configuration; + $this->plugin_id = $plugin_id; + } + /** * Information about options for all kinds of purposes will be held here. * @code @@ -185,8 +194,11 @@ function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $c /** * Let the handler know what its full definition is. */ - function set_definition($definition) { + function setDefinition($definition) { $this->definition = $definition; + if (isset($definition['id'])) { + $this->plugin_id = $definition['id']; + } if (isset($definition['field'])) { $this->real_field = $definition['field']; } @@ -352,16 +364,6 @@ function unpack_translatable(&$translatable, $storage, $option, $definition, $pa } } - /** - * The plugin type of this plugin, for example style or query. - */ - var $plugin_type = NULL; - - /** - * The plugin name of this plugin, for example table or full. - */ - var $plugin_name = NULL; - /** * Init will be called after construct, when the plugin is attached to a * view and a display. diff --git a/lib/Drupal/views/Tests/ModuleTest.php b/lib/Drupal/views/Tests/ModuleTest.php index 6cd8e3766b10473fd0a511c8f9c067adebc66cad..10d0165e647b32cd28a051ea7921b04429f3b857 100644 --- a/lib/Drupal/views/Tests/ModuleTest.php +++ b/lib/Drupal/views/Tests/ModuleTest.php @@ -111,7 +111,7 @@ function testviews_get_handler() { $types = array('field', 'area', 'filter'); foreach ($types as $type) { $handler = views_get_handler($this->randomName(), $this->randomName(), $type); - $this->assertEqual('views_handler_' . $type . '_broken', get_class($handler), t('Make sure that a broken handler of type: @type are created', array('@type' => $type))); + $this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), t('Make sure that a broken handler of type: @type are created', array('@type' => $type))); } $views_data = $this->viewsData(); @@ -160,6 +160,6 @@ function assertInstanceHandler($handler, $table, $field, $id) { $table_data = views_fetch_data($table); $field_data = $table_data[$field][$id]; - $this->assertEqual($field_data['handler'], get_class($handler)); + $this->assertEqual($field_data['id'], $handler->getPluginId()); } } diff --git a/views.api.php b/views.api.php index 6c0e1e8a83c20acf586df6f3c1a51e0eadff9110..be403c8f98c76c06e768704ac56225d686a2701d 100644 --- a/views.api.php +++ b/views.api.php @@ -50,7 +50,7 @@ * - Create the initial handler; at this time it is not yet attached to a * view. It is here that you can set basic defaults if needed, but there * will be no knowledge of the environment yet. - * - handler->set_definition() + * - handler->setDefinition() * - Set the data from hook_views_data() relevant to the handler. * - handler->init() * - Attach the handler to a view, and usually provides the options from the