Coder Social home page Coder Social logo

discoverable_entity_bundle_classes's People

Contributors

amcgowanca avatar douggreen avatar timodwhit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

discoverable_entity_bundle_classes's Issues

postLoad() hook not called correctly in SqlContentEntityStorageTrait

Current implementation

protected function postLoad(array &$entities) {
    $entity_class = $this->getEntityClass();
    $entity_class::postLoad($this, $entities);
    // Call hook_entity_load().
    foreach ($this->moduleHandler()
               ->getImplementations('entity_load') as $module) {
      $function = $module . '_entity_load';
      $function($entities, $this->entityTypeId);
    }
    // Call hook_TYPE_load().
    foreach ($this->moduleHandler()
               ->getImplementations($this->entityTypeId . '_load') as $module) {
      $function = $module . '_' . $this->entityTypeId . '_load';
      $function($entities);
    }
  }

does not determine entity_class of used entity bundle, but rather of the given parent entity, as there is no parameter given to getEntityClass().

I suggest to invoke the postLoad hook by bundle. Maybe like following.

protected function postLoad(array &$entities) {
    // We have to determine the bundle first.
    $bundle = FALSE;
    if (!empty($entities) && isset($this->bundleKey)) {
      $entity = reset($entities);
      $bundle = $entity->get($this->bundleKey)->getString();
    }
    $entity_class = $this->getEntityClass($bundle);
    $entity_class::postLoad($this, $entities);
    // Call hook_entity_load().
    foreach ($this->moduleHandler()
               ->getImplementations('entity_load') as $module) {
      $function = $module . '_entity_load';
      $function($entities, $this->entityTypeId);
    }
    // Call hook_TYPE_load().
    foreach ($this->moduleHandler()
               ->getImplementations($this->entityTypeId . '_load') as $module) {
      $function = $module . '_' . $this->entityTypeId . '_load';
      $function($entities);
    }
  }

drupal 9?

Is the module compatible with D9? Is maintenance still happenning?

mapFromStorageRecords() method was changed in Drupal 8.6.x

As of Drupal 8.6.x the mapFromStorageRecords() method in the SqlContentEntityStorage class was changed. These changes should also be represented in the SqlContentEntityStorageTrait of the discoverable_entity_bundle_classes module.

I will send a pull request when I am done testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.