AppParam not populating anymore after upgrading to 9.2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kharg
    Senior Member
    • Jun 2021
    • 476

    #1

    AppParam not populating anymore after upgrading to 9.2.0

    Hello,

    My issue is quite peculiar, after upgrading to Espo 9.2.0 my AppParam is undefined.

    As far as I've seen there have been no compatibility changes that would warrant this behavior.

    This is my frontend view:

    PHP Code:
    define('leaflet:views/settings/fields/forward-geocoder-provider', ['views/fields/enum'], (Dep) => {
      
        return class extends 
    Dep {
            
    setup() {
                
    super.setup();
                
    this.setupOptions();
            }
            
    setupOptions() {
                const 
    leafletConfig this.getHelper().getAppParam('Leaflet');
                
    this.params.options leafletConfig Object.keys(leafletConfig) : [''];
              
                if (
    this.params.options.length === 0) {
                    
    this.params.options = [''];
                }
            }
        };
    }); 
    and this is my AppParams class:

    PHP Code:
    <?php
    namespace Espo\Modules\Leaflet\Classes\AppParams;
    use 
    Espo\ORM\EntityManager;
    use 
    Espo\Tools\App\AppParam;
    class 
    Leaflet implements AppParam
    {
        private 
    EntityManager $entityManager;
        public function 
    __construct(EntityManager $entityManager)
        {
            
    $this->entityManager $entityManager;
        }
        public function 
    get(): array
        {
            
    $repository $this->entityManager->getRDBRepository('Integration');
          
            
    $list $repository
                
    ->select(['id'])
                ->
    where([
                    
    'enabled' => true,
                    
    'data*' => '%Leaflet%'
                
    ])
                ->
    find();
            
    $result = [
                
    'Nominatim' => [
                    
    'id' => 'nominatim',
                    
    'name' => 'Nominatim',
                ],
            ];
            foreach (
    $list as $item) {
                
    $result[$item->id] = [
                    
    'id' => $item->id,
                    
    'name' => $item->id,
                ];
            }
            return 
    $result;
        }
    }
    of course I also have the correct metadata in app->appParams.json

    PHP Code:
    {
        
    "Leaflet": {
            
    "className""Espo\\Modules\\Leaflet\\Classes\\AppParams\\Leaflet"
        
    }
    }
    ​ 
    Any suggestions on what could be wrong?
  • a.slyzhko
    Senior Member
    • Oct 2023
    • 119

    #2
    You are looping over an EntityCollection, not a regular array or stdclass. So you need to use a proper method getId() or get('someAttribute')

    Comment


    • Kharg
      Kharg commented
      Editing a comment
      Thank you, I will try to fix it like suggested and comment back if it works

    • Kharg
      Kharg commented
      Editing a comment
      You were totally right, I had forgot about this change.

      Now it works
Working...