This are "use" statements (some of them are needed for other functions) and the function from my custom module. On my localhost it was working as a charm:
use DrupalCoreRoutingRouteMatchInterface; use DrupalCoreFormFormStateInterface; use DrupalgroupEntityGroup; use DrupalgroupEntityGroupInterface; use Drupalopigno_group_managerControllerOpignoGroupManagerController; use Drupalopigno_group_managerEntityOpignoGroupManagedContent; use DrupalCoreUrl; use Drupalopigno_learning_pathPluginBlock; use Drupaltft; use DrupalCoreRoutingRouteMatchInterface; use DrupalCoreFormFormStateInterface; use DrupalgroupEntityGroup; use DrupalgroupEntityGroupInterface; use Drupalopigno_group_managerControllerOpignoGroupManagerController; use Drupalopigno_group_managerEntityOpignoGroupManagedContent; use DrupalCoreUrl; use Drupalopigno_learning_pathPluginBlock; use Drupaltft; use DrupaltftControllerTFTController; use DrupaltftControllerTFTController; function npx_main_theme() { /** @var DrupalgroupEntityGroup $group */ $group = Drupal::routeMatch()->getParameter('group'); if($group instanceof GroupInterface){ $tft_controller = new TFTController; $subfolder = $tft_controller->listGroup($group); return [ 'opigno_documents_last_group_block' => [ 'variables' => [ 'subfolder' => $subfolder ] ] ]; } }
However when I tried to make it run on dev server, it didn’t display the $subfolder, acting like it was empty. When I added kint($subfolder); like that:
function npx_main_theme() { /** @var DrupalgroupEntityGroup $group */ $group = Drupal::routeMatch()->getParameter('group'); if($group instanceof GroupInterface){ $tft_controller = new TFTController; $subfolder = $tft_controller->listGroup($group); kint($subfolder); return [ 'opigno_documents_last_group_block' => [ 'variables' => [ 'subfolder' => $subfolder ] ] ]; } }
it suddenly started to work, displaying all the subfolders and files. After I removed kint line it is still working, regardless clearing the cache. What is the reason and how can I change the code to display the files on new instances without using "kint" trick?