src/Service/NT8PropertyService.php
public function loadNodesFromPropref(string $propref, bool $load = TRUE) {
    // Get the nodes to update with this data.
    $nodeQuery = $this->entityQuery->get('node');
    $nodeStorage = $this->entityTypeManager->getStorage('node');
    $nids = $nodeQuery->condition('field_cottage_reference_code.value', $propref, '=')->execute();

    if (!$load) {
      return $nids;
    }

    $nodes = $nodeStorage->loadMultiple($nids);

    if (count($nodes) === 0) {
      \Drupal::logger('NT8PropertyService')->notice("Could not load a node for this propref: @propref", ['@propref' => print_r($propref, TRUE)]);
      $nodes = NULL;
    }

    return $nodes;
  }
public function loadNodesFromPropref(string $propref, bool $load = TRUE) {
    // Get the nodes to update with this data.
    $nodeQuery = $this->entityQuery->get('node');
    $nodeStorage = $this->entityTypeManager->getStorage('node');
    $nids = $nodeQuery->condition('field_cottage_reference_code.value', $propref, '=')->execute();

    if (!$load) {
      return $nids;
    }

    $nodes = $nodeStorage->loadMultiple($nids);

    if (count($nodes) === 0) {
      \Drupal::logger('NT8PropertyService')->notice("Could not load a node for this propref: @propref", ['@propref' => print_r($propref, TRUE)]);
      $nodes = NULL;
    }

    return $nodes;
  }
public function loadNodesFromPropref ( string $ propref , bool $ load = TRUE ) { // Get the nodes to update with this data. $ nodeQuery = $ this -> entityQuery -> get ( 'node' ) ; $ nodeStorage = $ this -> entityTypeManager -> getStorage ( 'node' ) ; $ nids = $ nodeQuery -> condition ( 'field_cottage_reference_code.value' , $ propref , '=' ) -> execute ( ) ; if ( ! $ load ) { return $ nids ; } $ nodes = $ nodeStorage -> loadMultiple ( $ nids ) ; if ( count ( $ nodes ) === 0 ) { \ Drupal :: logger ( 'NT8PropertyService' ) -> notice ( "Could not load a node for this propref: @propref" , [ '@propref' => print_r ( $ propref , TRUE ) ] ) ; $ nodes = NULL ; } return $ nodes ; }
Loads property nodes which have the same propref as the one provided.

@param string $propref
Property reference to query for.
@param bool $load
True: Return loaded node objects.
False: Make no attempt to load and return an array of NIDs.

@return array|\Drupal\Core\Entity\EntityInterface[]|int|null
An array of loaded property entities indexed by NID if $load = true
otherwise an array of NIDs.

@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Loads property nodes which have the same propref as the one provided .