1

I've been trying to get Connections to use a customised adapter located at app/extensions/data/source/database/adapter/. I thought extending the Connections class and replacing

protected static $_adapters = 'data.source';

with

protected static $_adapters = 'adapter.extension.data.source';

and changing the connections class used at the top of app/config/bootstrap/connections.php to use app\extensions\data\Connections; would be enough to get it started. However this just leads to a load of errors where the code is still trying to use the original Connections class.

Is there a simple way to achieve this, or do I have to recreate the entire set of classes from lithium/data in extensions with rewritten class references?

EDIT: Turns out I was going about this the wrong way. After following Nate Abele's advice, Libraries::path('adapter') showed me where to correctly place the MySql.php file I'm trying to override ;-)

Archer
  • 11
  • 3

1 Answers1

1

For dealing with how named classes (i.e. services, in the abstract) are located, you want to take a look at the Libraries class, specifically the paths() method, which allows you to define how class paths are looked up.

You can also look at the associated definitions, like locate() and $_paths, to give you an idea of what the default configuration looks like.

Finally, note that the Connections class is 'special' since it defines one path dynamically, based on the supplied configuration: http://li3.me/docs/api/lithium/1.0.x/lithium/data/Connections::_class()

This should help you reconfigure how your classes are organized without extending/overriding anything. Generally you shouldn't need to do that unless you need some drastically different behavior.

Nate Abele
  • 5,771
  • 32
  • 27
  • Also, feel free to follow up with code examples showing what you're doing, and/or the error messages you're getting. – Nate Abele May 08 '17 at 17:30
  • Hi Nate. After reading your reply and studying the Libraries::paths() docs and code I've edited my original question. – Archer May 10 '17 at 12:55