简体   繁体   中英

Cakephp 3.x How to set up with 3rd parties?

I don't know if this is the best title. Correct me if I am wrong, folks. Now to explain what I am asking about.

We have a company that ships out products that are sold by multiple vendors. These vendors all have different POS (Point of Sale) systems. There are probably about 5 different POS systems. Which means that each of the database tables are different for each POS system. We sync with their database where there POS stores the data to our server. So, what I am trying to do in our cakephp application is to create an Object Interface and then create separate classes(for each POS) that implement the interface to pull the data and centralize it. I was thinking of doing this by place these classes in the Vendor directory and then using a config to tell it which models to use in my application. Is this the way to go about it or does this break MVC pattern???

EDIT: I am going to explain in more details about what I have to work with. Right now there are two of the 5 POS systems that we are working with primarily. After synchronizing with their database I have the following tables in my database now.

[POS1] => [
   customers=>[
      'id', 'FIRSTNAME', 'LASTNAME'
   ],
   products=>[
      'id', 'TYPE', 'TITLE', 'PRICE'
   ],
   'orders'=>[
       'id', 'PRODUCT_ID' 
    ],
    'transactions'=>[
       'id', 'ORDER_ID', 'CUSTOMER_ID'
     ]
];
[POS2] => [
   customers=>[
      'id', 'name'
   ],
   products=>[
      'id', 'price'
  ],
  transactions=>[
       'id', 'order_id', 'customer_id'
     ]
];

Vendor is usually "third party stuff", you want to build something for your app not really using external third party libs. So it's going to become a part of you app.

I would put these new libs in App/Lib or App/Pos and then implement a factory pattern and and abstract class that implements the generic methods that they'll all have in common.

use App/Pos/PosSystem;
/* ... */
$Pos = PosSystem::get('SomeName');
$Pos->save($data);
$Pos->read('...');

Edit:

What you need is basically just an array transformation that will turn your POS data in a unified structure. With CakePHP 3.0 I think there are several ways to get this done. Maybe a decorator (haven't used them yet myself), a custom entity object or pretty classic a behavior.

I don't think you need any custom classes for that are outside of what CakePHP 3.0 already provides. You just need to transform the data structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM