Ok, here is what I did. I created managers for different types of classes that will be accessed with a variety of queries. The managers can be instantiated by themselves, but I also included them into a static registry type thing for ease of use.
Secondly I kind of nested the access to the managers based on the namespace, so some of the managers also contain a static registry of other managers.
One of the primary reasons for using managers in this way (with the static / nested registry) is that there will be a lot of use of these objects, so it will help with typing out all the pear names, and also I am trying to provide a really simple intuitive api to other programmers as I am the backend guy, and they do the views and controller stuff.
Here is what it looks like now. I find it a lot more intuitive than using the static methods like I had before, also now my model classes aren't cludged with a bunch of static methods.
Code: Select all
// Access FCP_Managers_OrderMgr and get an order based on an orderID
$order = FCP::orders()->find($orderID) ;
// Print the skus of the items on backorder
foreach( $order->backorders() as $backorder )
{
echo $backorder->getSKU() ;
}
// Get the shipment for an order using the orderID, this uses an instance of FCP_Managers_Order_ShipmentMgr
$shipment = FCP::orders()->shipments()->findByOrderID($orderID) ;
// Get a paged collection of products using a clientID and the product manager
$products = FCP::products()->getPageForClient($_GET['page'], $clientID) ;
echo $products->drawPaginateMenu() ;
foreach( $products as $product )
{
echo $product->getSKU() ;
}