title: Fatal error: Call to a member function schemaCollection() on a non-object in ...vendor/cakephp/cakephp/src/ORM/Table.php on line 421
body: <p>Hi everyone and happy Easter !</p>
  
  <p>I have this problem in migrating a legacy application from CakePHP 2.x to CakePHP 3.x</p>
  
  <p>I am trying to load all the contents of a database table in the initialize function of the model (ConfigurationsTable.php - made into a Singleton) class. I also tried the same code in the constructor but still get the same error. Also tried moving it to a separate function but still no luck.</p>
  
  <p>It works fine in CakePHP 2.x but I get a fatal error in CakePHP 3.</p>
  
  <p>Code is as follows</p>
  
  <pre><code>namespace App\Model\Table;
  
  use Cake\ORM\Table;
  use Cake\Validation\Validator;
  
  class ConfigurationsTable extends Table
  {
  
  private $_configurations;
  
  public static function getInstance()
  {
      static $instance = null;
  
      if ($instance === null) {
          $instance = new static();
      }
  
      return $instance;
  }
  
  public function is_set($key)
  {
      return isset($this-&gt;_configurations-&gt;{$key});
  }
  
  public function fetch($key)
  {
      return $this-&gt;_configurations-&gt;{$key};
  }
  
  public function initialize(array $config)
  {
      $this-&gt;addBehavior('Timestamp');
  
      $this-&gt;_configurations = new \stdClass();
  
      $configs = $this-&gt;find('all');
  
      foreach ($configs as $c) {
          if (isset($c-&gt;key) &amp;&amp; $c-&gt;key != '') {
              $this-&gt;_configurations-&gt;{$c-&gt;key} = $c-&gt;value;
          }
      }
  
  
  }
  
  
  public function validationDefault(Validator $validator)
  {
      $validator
          -&gt;notEmpty('key')
          -&gt;add('key', [
              'unique' =&gt; [
                  'rule' =&gt; 'validateUnique',
                  'provider' =&gt; 'table',
                  'message' =&gt; __('This configuration key already exists')
              ]
          ])
          -&gt;notEmpty('value')
          ;
  
      return $validator;
  }
  </code></pre>
  
  <p>The line that's causing the error is: $configs = $this->find('all');</p>
  
  <p>Can anyone provide me a solution for this ?
  I need it for work..</p>
  
  <p>Thanks a lot in advance</p>