OutlineProxyGenerator::generate()

4 views
Skip to first unread message

mindplay.dk

unread,
Aug 3, 2010, 12:24:03 AM8/3/10
to Outlet ORM
I propose the following minor extension - it's backwards compatible:

<code>
function generate ($array=false) {
$c = array();
foreach ($this->config->getEntities() as $entity) {
$clazz = $entity->clazz;

$s = "class {$clazz}_OutletProxy extends $clazz implements
OutletProxy { \n";
$s .= " static \$_outlet; \n";

foreach ($entity->getAssociations() as $assoc) {
switch ($assoc->getType()) {
case 'one-to-many': $s .= $this-
>createOneToManyFunctions($assoc); break;
case 'many-to-one': $s .= $this-
>createManyToOneFunctions($assoc); break;
case 'one-to-one': $s .= $this->createOneToOneFunctions($assoc);
break;
case 'many-to-many': $s .= $this-
>createManyToManyFunctions($assoc); break;
default: throw new Exception("invalid association type: {$assoc-
>getType()}");
}
}
$s .= "} \n";
$c[$clazz.'_OutletProxy'] = $s;
}

return $array ? $c : implode('', $c);
}
</code>

This would enable me to work around a performance issue with Outlet...
because all of the proxies are written to a single file, they
currently cause all of the model classes in my application to autoload
instantly - not a very scalable approach.

By extending this method, I can write out the Proxy classes to
individual files, enabling them to autoload.

The OutletAdapter I've written for Yii works nicely now, just these
minor issues to work around, and not much I can do on my side of the
fence without hacking the Outlet source code, which I would strongly
prefer to avoid...
Reply all
Reply to author
Forward
0 new messages