Problem/Motivation

Clean up the code, and use some functions.

Remaining tasks

Get it done.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tonytheferg created an issue. See original summary.

tonytheferg’s picture

Status: Active » Needs review
StatusFileSize
new6.97 KB

Not sure if this is overkill, but it sure is cleaner. :)

rohan-sinha’s picture

Status: Needs review » Needs work

Reviewed the patch, looks optimized, suggestions
if (!empty($this->getNid())) {
if ($this->getAgreeNode()) {

Instead can be used:
if ((!empty($this->getNid()) && ($this->getAgreeNode())) {

mukesh88’s picture

StatusFileSize
new7.25 KB
new1.04 KB

#3 suggested code optimized fixed and recreate patch.

mukesh88’s picture

Status: Needs work » Needs review
tonytheferg’s picture

Actually, the getAgreeNode function already checks for nid:

public function getAgreeNode() {  
  if (!$this->getNid()) {  
    return NULL; 
  }  
  return $this->entityTypeManager->getStorage('node')->load($this->getNid());

So using both would be redundant.

But the getAgreeNode function needs an else statement.

tonytheferg’s picture

Status: Needs review » Needs work
tonytheferg’s picture

StatusFileSize
new1.33 KB
new6.98 KB
tonytheferg’s picture

Status: Needs work » Needs review
StatusFileSize
new708 bytes
new6.99 KB

Actually, I like this better than the else statement:

  /**
   * {@inheritdoc}
   */
  public function getAgreeNode() {
    $node = NULL;
    if (!empty($this->getNid())) {
      $node = $this->entityTypeManager->getStorage('node')->load($this->getNid());
    }
    return $node;
  }
tonytheferg’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
anybody’s picture

Might be a good idea to create a MR instead for better comparison?

vitaliyb98 made their first commit to this issue’s fork.

vitaliyb98’s picture

Added changes from the patch to the MR. Also, merge changes from https://www.drupal.org/project/commerce_agree_terms/issues/3552547, which contains some tests and a pipeline, which will help to validate these changes. Also, it is a good idea to add additional tests.

vitaliyb98’s picture

Status: Needs review » Reviewed & tested by the community

Sync code with 2.0.x. LGTM.

vitaliyb98’s picture

Status: Reviewed & tested by the community » Fixed

Merged into 2.0.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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