Error in sample code for entityManager

Created on 22 April 2020, over 4 years ago
Updated 13 February 2024, 9 months ago

The sample code to copy & paste after creating a new Oracle connection appears to use an older and now broken version of the entityManager functions. This did not work for me

For example, here is the code block I was given to copy & paste:

$entity_storage = \Drupal::entityTypeManager()->entityManager->getStorage("drupacle_connection"); 
$entity = $entity_storage->load("wfora"); 
$connObj = \Drupal::service("drupacle.connection_service")->drupalConnectionCallback($entity);
$Sql = oci_parse($connObj["wfora"], "YOUR QUERY"); 

This would result in errors like:
Notice: Undefined property: Drupal\Core\Entity\EntityTypeManager::$entityManager
Error: Call to a member function getStorage() on null

I was able to get this running by changing the first line to:

 $entity_storage = \Drupal::entityManager()->getStorage("drupacle_connection");

Not sure if that is exactly the correct way to do it but, it seems to be working now and also is closer to the example currently provided in the documentation.

🐛 Bug report
Status

Fixed

Version

1.3

Component

User interface

Created by

🇺🇸United States Neil N

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024