Updated: Comment #6

Problem/Motivation

In ViewExecutable several methods dealing with Views handlers are using ...Item() instead. Especially as ViewExecutable::getItemsPerPage() and ViewExecutable::setItemsPerPage() are used in a total different context this may be very confusing.

Proposed resolution

Renaming the following methods to use "Handler" instead of "Item":

  • addItem() => addHandler()
  • generateItemId() => generateHandlerId()
  • getItems() => getHandlers()
  • getItem() => getHandler()
  • removeItem() => removeHandler()
  • setItemOption() => setHandlerOption()

Remaining tasks

-

User interface changes

-

API changes

Public methods of \Drupal\views\ViewExecutable are renamed:

  • addItem() => addHandler()
  • generateItemId() => generateHandlerId()
  • getItems() => getHandlers()
  • getItem() => getHandler()
  • removeItem() => removeHandler()
  • setItemOption() => setHandlerOption()

Developers dealing with handlers associated to a view need to rename their method calls.
The AddItem form is now called AddHandler.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

derhasi’s picture

Issue summary: View changes
derhasi’s picture

derhasi’s picture

Status: Active » Needs review

There's the patch ^^.

There are two things I very much would get feedback for:

  • I'm not sure if we should use "Handler" or "HandlerInstance" for the method names.
  • If \Drupal\views_ui\Form\Ajax\AddItem really only deals with handlers.
dawehner’s picture

I'm not sure if we should use "Handler" or "HandlerInstance" for the method names.

I do prefer using getHandler() over getHandlerInstance().

dawehner’s picture

OH and yes, I am fine with renaming the AddItem form as well!

derhasi’s picture

There's the update with the Form changed and hopefully all references in description updated.

Status: Needs review » Needs work

The last submitted patch, 6: viewexecutable-naming-item-to-handler-2143495-6.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: viewexecutable-naming-item-to-handler-2143495-6.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
30.92 KB
67.13 KB

Continued with doing the work on that and potentially fixed the test failure.

tim.plunkett’s picture

+1 for the naming change.
I'll be back for a full review when it passes.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

I think this is pretty good already. Nice work.

star-szr’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Tagging for reroll.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
66.39 KB

Here is one.

Status: Needs review » Needs work

The last submitted patch, 14: vdc-2143495.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
67.13 KB

OH i missed the move in the last reroll.

Status: Needs review » Needs work

The last submitted patch, 16: vdc-2143495.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
68.52 KB
1.82 KB

Let's fix the last one.

damiankloip’s picture

+++ b/core/modules/views_ui/views_ui.routing.yml
@@ -120,14 +120,14 @@ views_ui.break_lock:
+  path: '/admin/structure/views/{js}/add-handler/{view}/{display_id}/{type}'

+++ b/core/modules/views_ui/views_ui.module
@@ -215,13 +215,13 @@ function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type
+      'href' => "admin/structure/views/nojs/config-handler/{$view->storage->id()}/{$display['id']}/$type/$id",

+++ b/core/modules/views_ui/views_ui.routing.yml
@@ -204,38 +204,38 @@ views_ui.form_display:
+  path: '/admin/structure/views/{js}/config-handler-extra/{view}/{display_id}/{type}/{id}'

If we're changing these paths anyway, do you think it's worth us improving them slightly? Getting rid of the 'config-' part for starters maybe.

dawehner’s picture

FileSize
67.73 KB

I would like to get the patch as straightforward as possible though I agree about the paths.
Damnit I hate that we don't use routes on there already. this would make things trivial.

Status: Needs review » Needs work

The last submitted patch, 20: vdc-2143495.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

20: vdc-2143495.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 20: vdc-2143495.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
68.11 KB
862 bytes
tim.plunkett’s picture

Issue tags: -DX +DX (Developer Experience)
dawehner’s picture

24: vdc-2143495.patch queued for re-testing.

dawehner’s picture

Priority: Normal » Major

Given how much this really make it easier to understand what getItem() is for.

dawehner’s picture

24: vdc-2143495.patch queued for re-testing.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

Agreed, it really does. It's a big benefit for such a simple change.

derhasi’s picture

Thanks for re-re-re-re-re-rolling. Great work!

webchick’s picture

Title: Improve naming of ViewExecutable::addItem(), ::getItem() & Co. » Change notice: Improve naming of ViewExecutable::addItem(), ::getItem() & Co.
Status: Reviewed & tested by the community » Active
Issue tags: +Approved API change, +Needs change record

"Item" is a generic-enough word that agreed it doesn't make much sense to use it when there's another, more descriptive noun available. Especially if we're using "Item" elsewhere to mean something totally different.

Committed and pushed to 8.x. Thanks!

This'll need a change notice.

Les Lim’s picture

Assigned: derhasi » Unassigned

Unassigning for the change notice writeup.

lexfunk’s picture

Assigned: Unassigned » lexfunk

Assigning to myself for change notice writeup.

lexfunk’s picture

Title: Change notice: Improve naming of ViewExecutable::addItem(), ::getItem() & Co. » Improve naming of ViewExecutable::addItem(), ::getItem() & Co.
Assigned: lexfunk » Unassigned
Priority: Major » Normal
Status: Active » Fixed
Issue tags: -Needs change record

I created the change record: https://drupal.org/node/2181701.

dawehner’s picture

Nice!

Status: Fixed » Closed (fixed)

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