createFromStorageRecord example

->getEntityTypeManager()
          ->getStorage($entity_type);

        $id = $entity_storage->getIDFromConfigName($name$entity_storage->getEntityType()->getConfigPrefix());
        // It is possible that secondary writes can occur during configuration         // creation. Updates of such configuration are allowed.         if ($this->getActiveStorages($collection)->exists($name)) {
          $entity = $entity_storage->load($id);
          $entity = $entity_storage->updateFromStorageRecord($entity$new_config->get());
        }
        else {
          $entity = $entity_storage->createFromStorageRecord($new_config->get());
        }
        if ($entity->isInstallable()) {
          $entity->trustData()->save();
          if ($id !== $entity->id()) {
            trigger_error(sprintf('The configuration name "%s" does not match the ID "%s"', $name$entity->id()), E_USER_WARNING);
          }
        }
      }
      else {
        $new_config->save(TRUE);
      }
    }
Home | Imprint | This part of the site doesn't use cookies.