Notice: Only variables should be passed by reference [closed]

I am new to drupal and not a coding expert. I get this error: Only variables should be passed by reference in include() for the lines $tmp->role = count($parent->getRoles()) ? end($parent->getRoles()) : ”;

public function getRelations($isAll = false){     $user = DrupaluserEntityUser::load(Drupal::currentUser()->id());     if ($isAll) {         /** @var UserService $userService */         $userService = Drupal::service('avofamilles.user_services');         $relations = $userService->getAllRelations($user->id());     } else {         $relations = $user->get('field_relations')->getValue();     }     $data_relations = [];     if ($relations) {         foreach ($relations as $relation){             /** @var User $parent */             $parent = DrupaluserEntityUser::load($relation['target_id']);             if (!$parent) {                 continue;             }             $civility_relation = $parent->get('field_civility')->value;             $civility = "";             if ($civility_relation == "father") {                 $civility = "Ex-Compagnon";             } else if ($civility_relation == "mother") {                 $civility = "Ex-Compagne";             } else {                 $civility = "Avocat";             }             $image_relation = $parent->get('user_picture')->getValue();             $avatar_relation = '';             if (isset($image_relation[0]['target_id'])) {                 $file = File::load($image_relation[0]['target_id']);                 $avatar_relation = file_create_url($file->getFileUri());             }             $tmp = new stdClass();             $tmp->uid = $relation['target_id'];             $tmp->name = $parent->field_firstname->value;             $tmp->email = $parent->getEmail();             $tmp->civility = $civility;             $tmp->couleur = $parent->get('field_couleur')->value;             $tmp->avatar = $avatar_relation;             $tmp->avatar_url = $parent->get("field_avatar")->value;             $tmp->is_waiting = $parent->get("field_is_waiting")->value;                       $tmp->role = count($parent->getRoles()) ? end($parent->getRoles()) : '';             $tmp->roles = $parent->getRoles()[1] ? : null;              $data_relations[] = $tmp;         }     }     return $data_relations; } 

}

Can anybody see what is wrong ? Thank you for you help

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Notice: Only variables should be passed by reference [closed]

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.