Problem/Motivation

Embrace D8 API.

Proposed resolution

Convert d7 vud widgets implemented as ctools plugins into d8 core plugins.

Remaining tasks

  • Define the new plugin type vud_widget.
  • Write a test module containing a vud widget.
  • Write a test that loads and checks plugin metadata from the defined test module.
  • Convert all vud widgets into d8 plugins.

User interface changes

None, this is not about UI, but about the underlying internal API.

API changes

Any custom vud widget will need to change entirely to be a d8 plugin of the type that will be defined for vud widgets.

Data model changes

Inherent in the d8 plugin conversion.

Original report by marvil07

So it would be easier to create widgets based on a parent widget, and changing i.e. only the sprite.

Patches welcome

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marvil07’s picture

Title: Move to oop ctools plugins » Convert vud widgets into D8 plugins
Version: 7.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes
Parent issue: » #2844432: Port vud to D8

Re-purposing this ticket as the d8 plugins conversion, since d7 ctools oop will not be done at this point.

marvil07’s picture

marvil07’s picture

One example test for Sudhanshu reference.

sudhanshug’s picture

Queuing the latest changes with Unit test for tests

sudhanshug’s picture

Status: Active » Needs review
sudhanshug’s picture

Queing the complete patch for tests

sudhanshug’s picture

sudhanshug’s picture

marvil07’s picture

Status: Needs review » Needs work

  • marvil07 committed de9716e on 8.x-1.x authored by sudhanshug
    Issue #1426398 by sudhanshug: Converts vud widgets into D8 plugins.
    
marvil07’s picture

Status: Needs work » Fixed

After some more back and forth on github, I am happy to incorporate the latest code about this.

Here a script I used to test this code and its output, which suggests more work is needed still, but it probably is about passing the right variables to the template.

Code:

if (!\Drupal::hasService('plugin.manager.vud')) {
    die('cannot find service');
}
echo 'service found' . PHP_EOL;
$vud_manager = \Drupal::service('plugin.manager.vud');

if (!$plain_definition = $vud_manager->getDefinition('plain')) {
    die('cannot find plain widget');
}
echo 'plain widget definition found' . PHP_EOL;

if (!$plain_instance = $vud_manager->createInstance('plain')) {
    die('cannot create plain instance');
}
echo 'plain widget instance created' . PHP_EOL;

$built_widget = $plain_instance->build();
echo 'plain widget could be build' . PHP_EOL;

\Drupal::service('renderer')->renderPlain($built_widget);
echo 'plain widget could be rendered' . PHP_EOL;

Output:

service found
plain widget definition found
plain widget instance created
plain widget could be build
plain widget could be rendered
  <div class="vud-widget vud-widget-plain" id="">
        <a href="" rel="nofollow" class="">
            <span class="" title="Vote up!"></span>
      <div class="element-invisible">Vote up!</div>
          </a>
            <a href="" rel="nofollow" class="">
            <span class="" title="Vote down!"></span>
      <div class="element-invisible">Vote down!</div>
          </a>
              <a href="" rel="nofollow" class="" title="">
        <div class="">
          
        </div>
      </a>
      </div>

Let's continue on a follow-up tickets as needed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.