CakePHP 3 - Plugin table not found in associations when saving
<p>I have a plugin which contains all the tables it uses.</p>

<pre><code>plugins
  /MyPlugin
    /src
      /Model
        /Table
          EventsTable.php
          EventValuesTable.php
          ...
</code></pre>

<p>I am trying to save an <code>Event</code> entity and its related hasMany <code>EventValues</code> association.</p>

<pre><code>$data = [
    'event_type_id' =&gt; 5,
    'event_values' =&gt; $values // An array of EventValue entities
];
$event = $eventsTable-&gt;newEntity($data, [
    'associated' =&gt; ['MyPlugin.EventValues']
]);
</code></pre>

<p>However, it cannot find the associated table and gives the following error:</p>

<p><strong>Cannot marshal data for "MyPlugin" association. It is not associated with "Events"</strong></p>

<hr>

<p>Now I have spent hours debugging this, and here is where I am so far:</p>

<ul>
<li><p>The exception is thrown from a new piece of code introduced to the Cake core in version 3.3</p></li>
<li><p>The exception is thrown from <a href="http://api.cakephp.org/3.3/source-class-Cake.ORM.Marshaller.html#94-98" rel="nofollow">\Cake\ORM\Marshaller.php (Line 94)</a> when it's trying to break down the <code>associated</code> array.</p></li>
</ul>

<p><strong>The Problem:</strong></p>

<p>The <code>Marshaller</code> class seems to be treating the <code>MyPlugin.EventValues</code> association as a nested model association - i.e. It thinks <code>MyPlugin</code> is the name of a model related to the main entity being saved (<code>Event</code>). It's not looking for the model in my plugin's <code>src/Table</code> directory.</p>

<p>I need to find a way to get Cake to realise that <code>MyPlugin.EventValues</code> means:</p>

<pre><code>plugins/MyPlugin/src/Model/Table/EventValuesTable.php
</code></pre>

<p>Instead, it's analysing it as:</p>

<pre><code>src/Model/Table/MyPluginsTable.php
</code></pre>

<p>So my question is:</p>

<ol>
<li>Is this a Cake bug which has been introduced?</li>
<li>If not, how can I tell it to make the association from my plugin tables?</li>
</ol>

<p>I know the first thing you guys will ask is to see my model associations and everything, BUT this was working before updating from Cake 3.1 to 3.3, and I am 100% sure the associations are correct. Remember all the tables are in the plugin table directory, nothing is from the main app table directory.</p>