After discussion with damiankloip, dawehner and alexpott on IRC we concluded that this issue isn't a part of #2016679: Expand Entity Type interfaces to provide methods, protect the properties as previous stated.

Instead we concluded this should be about refactoring ViewStorageInterface to ViewEntityInterface. The problem with the ViewStorageInterface is that it suggest that is extending the EntityStorageInterface and it does not. The ViewStorageInterface is extending the ConfigEntityInterface and it will be better for the developer experience if the interface is renamed to ViewEntityInterface.

Also is the class variable $id being set from public to protected.

TODO
- 3 small updates to the current patch. See the comment #33 from @alexpott.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Thomas Brekelmans’s picture

I've included a patch which adds:

getBaseTableName();
getBaseFieldName();
getDescription();
getTags();
getCoreVersion();
getViewExecutable();
getModuleName();

I didn't think including setters for any property made sense since most of these properties are set implicitly by the ViewExecutable through the system and shouldn't be modified individually, certainly not through the View entity directly I think?

Thomas Brekelmans’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, view-entity-expand-view-with-methods-2030667-1.patch, failed testing.

Thomas Brekelmans’s picture

Status: Needs work » Needs review

Not sure how this patch could fail since it only modifies documentation and adds code that isn't called yet (new methods), can anyone explain that or is this just a (temporary) test-bot failure?

Thomas Brekelmans’s picture

Status: Needs review » Needs work
Issue tags: +Entity Field API

The last submitted patch, view-entity-expand-view-with-methods-2030667-1.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
26.58 KB

I think it was the use Drupal\views\Drupal...
Anyway, we've also discussed renaming the interface, might as well do that here.

tim.plunkett’s picture

FileSize
1.64 KB
27.96 KB

Oh! I realized why the other patch failed. We needed to add this to ViewUI.

tim.plunkett’s picture

Issue tags: +VDC

Taggin.g

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/ViewInterface.php
@@ -0,0 +1,129 @@
+   * @return int

That is a string.

+++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php
@@ -15,12 +15,12 @@
@@ -141,10 +141,10 @@ class ViewUI implements ViewStorageInterface {

I think we should extend the test coverage of ViewUI then.

dawehner’s picture

Status: Needs review » Needs work

.

dawehner’s picture

Issue summary: View changes

Updated issue summary.

jibran’s picture

Status: Needs work » Needs review

8: vdc-2030667-8.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 8: vdc-2030667-8.patch, failed testing.

daffie’s picture

Issue summary: View changes
Issue tags: +Needs reroll

This patch is a year old so it needs a reroll

daffie’s picture

filijonka’s picture

Assigned: Unassigned » filijonka

working on this

filijonka’s picture

Status: Needs work » Needs review
FileSize
24.26 KB

ok this will not get back green but need to get some feedback from testbot.

notable changes

1. removed getViewExecutable and used getExecutable that is on head instead.

2. ViewExecutable __construct was wrong, the interface declared parameters that wasn't implemented, the dochead needs still to be updated for that.

3. newDisplay in View entity, not sure if it is really needed but let it stay.

Status: Needs review » Needs work

The last submitted patch, 17: 2030667-17.patch, failed testing.

filijonka’s picture

Status: Needs work » Needs review
FileSize
26.87 KB
3.44 KB

ok so hopefully this will be green now. and if it is then time to check if it do what we are aiming for.

filijonka’s picture

Issue tags: -Needs reroll
daffie’s picture

Status: Needs review » Needs work
  1. The class variable $id is not set protected.
  2. You have replaced ViewStorageInterface with ViewInterface. Why? It is not a rename action. The old one does not get deleted. Why?
  3. The ViewInterface is missing the definition of the method duplicateDisplayAsType().
  4. The EntityStorageInterface is not implemented for the views module.
  5. +++ b/core/modules/views/src/Entity/View.php
    @@ -461,4 +465,46 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getBaseTableName() {
    +    return $this->base_table;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getBaseFieldName() {
    +    return $this->base_field;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getDescription() {
    +    return $this->description;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getTags() {
    +    return $this->tag;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getCoreVersion() {
    +    return $this->core;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getModuleName() {
    +    return $this->module;
    +  }
    +
    
    +++ b/core/modules/views/src/ViewInterface.php
    @@ -0,0 +1,129 @@
    +  /**
    +   * Returns the name of the base table this view will use.
    +   *
    +   * @return string
    +   *   The name of the base table for this view.
    +   */
    +  public function getBaseTableName();
    +
    +  /**
    +   * Returns the name of the base field to use.
    +   *
    +   * @return string
    +   *   The name of the base field for this view.
    +   */
    +  public function getBaseFieldName();
    +
    +  /**
    +   * Returns the description of the view, which is used only in the interface.
    +   *
    +   * @return string
    +   *   The description of this view used in the interface.
    +   */
    +  public function getDescription();
    +
    +  /**
    +   * Returns the "tags" of a view.
    +   *
    +   * The tags are stored as a single string, though it is used as multiple tags
    +   * for example in the views overview.
    +   *
    +   * @return string
    +   *   A single string of multiple tags added to this view.
    +   */
    +  public function getTags();
    +
    +  /**
    +   * Returns the core version this view was created for.
    +   *
    +   * @return int
    +   *   A drupal core version string such as DRUPAL_CORE_COMPATIBILITY (8.x)
    +   */
    ...
    +  /**
    +   * Returns the name of module implementing this view.
    +   *
    +   * @return string
    +   *   The name of the module implementing this view.
    +   */
    +  public function getModuleName();
    

    Why do you add these methods. They are never used, so please remove them.

  6. +++ b/core/modules/views/src/ViewInterface.php
    @@ -0,0 +1,129 @@
    +  /**
    +   * Returns a reference to the executable version of this view.
    +   * If none was set previously, it is created before returning it.
    +   *
    +   * @return \Drupal\views\ViewExecutable
    +   *   A reference to the executable version of this view.
    +   */
    +  public function getExecutable();
    

    This method is not used and is not implemented by the class View.

  7. +++ b/core/modules/views_ui/src/ViewUI.php
    @@ -1168,4 +1168,66 @@ class ViewUI implements ViewStorageInterface {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
    +    return $this->storage->addDisplay($plugin_id, $title, $id);
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function newDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
    +    return $this->storage->newDisplay($plugin_id, $title, $id);
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getBaseTableName() {
    +    return $this->storage->getBaseTableName();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getBaseFieldName() {
    +    return $this->storage->getBaseFieldName();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getDescription() {
    +    return $this->storage->getDescription();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getTags() {
    +    return $this->storage->getTags();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getCoreVersion() {
    +    return $this->storage->getCoreVersion();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getViewExecutable() {
    +    return $this->storage->getViewExecutable();
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getModuleName() {
    +    return $this->storage->getModuleName();
    

    Why are these added? If $this->storage is the class View, then they inherit the methods from View. Also they are never used, so please remove them.

filijonka’s picture

Status: Needs work » Needs review
FileSize
27.98 KB
13.47 KB

ok so everything in comment #21 except for 21.1 for now. and 21.4 I don't understand that sentence.

dawehner’s picture

The issue needs a better issue summary and beta evaluation.

  1. +++ b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
    @@ -62,7 +62,7 @@ class NodeBulkFormTest extends UnitTestCase {
    -    $storage = $this->getMock('Drupal\views\ViewStorageInterface');
    +    $storage = $this->getMock('Drupal\views\ViewInterface');
    

    That itself makes sense now ... this is a relict from earlier times BUT the issue summary / beta evaluation should describe how much problems are potentially caused by renaming the interface (small, given that the interface name is not simple to fix).

  2. +++ b/core/modules/views/src/Entity/View.php
    @@ -461,4 +447,46 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getCoreVersion() {
    +    return $this->core;
    +  }
    +
    

    Can we open up a follow up to kill this ? I think its not something you really need anymore ... it used to be used for version updates between 6 and 7.

  3. +++ b/core/modules/views/src/ViewInterface.php
    @@ -53,4 +53,23 @@
    +  /**
    +   * Adds a new display handler to the view, automatically creating an ID.
    +   *
    +   * @param string $plugin_id
    +   *   (optional) The plugin type from the Views plugin annotation. Defaults to
    +   *   'page'.
    +   * @param string $title
    +   *   (optional) The title of the display. Defaults to NULL.
    +   * @param string $id
    +   *   (optional) The ID to use, e.g., 'default', 'page_1', 'block_2'. Defaults
    +   *   to NULL.
    +   *
    +   * @return string|bool
    +   *   The key to the display in $view->display, or FALSE if no plugin ID was
    +   *   provided.
    +   */
    +  public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL);
    

    In an ideal world the View should not have these methods but rather that logic should live in a separate place, but sure, this is out of scope of this issue.

filijonka’s picture

I thought that I had removed all not used functions from the View class but apparently only in the interface. done that in this and also protected the property id.

Renaming of the Class from ViewStorageInterface to ViewInterface is as far as I can see a clear API change and hence it shouldn't be done in this face we are know.

The effort to do the renaming and the effects of it seems to be small, I guess it wouldn't be a huge problem to change it back either. I think it wuld be best that we let committers take a look and let them decide.

daffie’s picture

Category: Task » Bug report
Issue summary: View changes

@filijonka: Good work!

In the class Entity/View you change the docblock for a number of public methods to inheritdoc. Can you do the same for the public method getExecutable().

For the rest of the patch is it RTBC from me.

daffie’s picture

Status: Needs review » Needs work
filijonka’s picture

waiting for a decision from view maintainers on this issue before going on.

dawehner’s picture

@filijonka
Please update the issue summary according to our conversation.

filijonka’s picture

Title: Expand View with methods » Refactoring ViewStorageInterface to ViewEntityInterface
Issue summary: View changes
Parent issue: #2016679: Expand Entity Type interfaces to provide methods, protect the properties »
filijonka’s picture

ok let's hope we got this right

filijonka’s picture

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

That itself looks fine!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

It would be nice if the summary could contain a justification for the interface rename. I know @dawehner and @damiankloip want to do this and I don;t think this is a disruptive change since everything outside of views that wants to typehint on a view would want a ViewExecutable - which is exactly what all the views plugins do.

  1. +++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php
    @@ -9,7 +9,7 @@
    -use Drupal\views\ViewStorageInterface;
    +use Drupal\views\ViewEntityInterface;
    
    +++ b/core/modules/views/src/Plugin/views/wizard/WizardInterface.php
    @@ -54,7 +54,7 @@
        *   The current state of the wizard form.
    

    Just remove the use - this is not used here.

  2. +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc
    @@ -7,7 +7,7 @@
    -use Drupal\views\ViewStorageInterface;
    +use Drupal\views\ViewEntityInterface;
    

    Remove the use - it's not used.

  3. +++ b/core/modules/views_ui/views_ui.module
    @@ -10,7 +10,7 @@
    -use Drupal\views\ViewStorageInterface;
    +use Drupal\views\ViewEntityInterface;
    

    Just remove ViewStorageInterface - it is not actually used in the file :)

daffie’s picture

Updated the IS with the justification of the interface rename.

Novice TODO:
- 3 small updates to the current patch. See the comment #33 from @alexpott.

adci_contributor’s picture

Status: Needs work » Needs review
FileSize
28.67 KB
1.44 KB

I'm trying to remove useless 'use'

daffie’s picture

Status: Needs review » Reviewed & tested by the community

It all looks good to me.
All the changes that are wanted by @alexpott are implemented.
Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

ViewsStorage/EntityInterface is not used in external typehints - ViewsExecutable is.

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed efbaa69 and pushed to 8.0.x. Thanks!

  • alexpott committed efbaa69 on 8.0.x
    Issue #2030667 by filijonka, tim.plunkett, adci_contributor, Thomas...
filijonka’s picture

Assigned: filijonka » Unassigned

thanks @daffie for updating the IS.

Status: Fixed » Closed (fixed)

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