Jump to content



Photo
- - - - -

shared classes between two Site


  • Please log in to reply
7 replies to this topic

#1   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 March 2012 - 11:45

Hi Harald,

another question.
in my scenario, i've cloned Admin Site with PublicAdmin Site.
for :

ApplicationAbstract.php
CategoryTree.php
Controller.php
Image.php
IndexModulesAbstract.php
Language.php
MessageStack.php
OrderTotal.php
PaymentModuleAbstract.php
ProductAttributeModuleAbstract.php
ServiceAbstract.php
Shipping.php
Tax.php
Template.php

my understanding is that these classes could be shared between these two Site :

[attachment=1075:sharedclasses.png]

Are you agree with this structure ?

Usually, i shouldn't cloned these classes in my PublicAdmin Site.

Edited by foxp2, 15 March 2012 - 11:47.

-------------------

#2   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 15 March 2012 - 12:15

Hi Laurent..

There is no need to duplicate code in that scenario. Calling the original classes should be fine. You will need to reference some classes though, example:

Admin\Controller calls MessageStack() from the same namespace osCommerce\OM\Core\Site\Admin. As you are in a different namespace, you will need to add

use osCommerce\OM\Core\Site\Admin\MessageStack;

to PublicAdmin\Controller so it uses the correct class.

Kind regards,

Edited by Harald Ponce de Leon, 15 March 2012 - 12:16.

Harald Ponce de Leon

#3   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 March 2012 - 12:21

Hi Harald,

thank you for your answer.


But once again, we have the same problem : too hardcoded code in these classes.
eg :
in \osCommerce\OM\Core\Site\Admin\Controller.php
      $application = 'osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Controller';

should be :

      $application = 'osCommerce\\OM\\Core\\Site\\' . OSCOM::getSite() . '\\Application\\' . OSCOM::getSiteApplication() . '\\Controller';
because my Application are in PublicSite

We have also a lot of OSCOM::callDB('Admin\ ...
instead of OSCOM::callDB(OSCOM::getSite()

I'm alright or i'm stupid ? /crying.gif' class='bbc_emoticon' alt=':'(' />
-------------------

#4   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 15 March 2012 - 12:37

Hi Laurent..

The $application line could be updated to use OSCOM::getSite() which can help in your scenario, however the OSCOM::callDB() lines should be left hardcoded to make sure the right classes are being called.

If this does not meet your needs, you will need to write your own Site Controller and not base it off an existing one.

Kind regards,

Edited by Harald Ponce de Leon, 15 March 2012 - 12:37.

Harald Ponce de Leon

#5   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 March 2012 - 12:57

Hi Harald,
ok, but IMO, once again ,I reach a limit in the flexibility. /wacko.png' class='bbc_emoticon' alt=':wacko:' />
-------------------

#6   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 15 March 2012 - 13:09

Hi Laurent..

First step: Get your code working
Second step: Look where the core framework can be improved (to remove flexibility limits)
Third step: Propose changes to the core framework

:thumbsup:

Kind regards,

Edited by Harald Ponce de Leon, 15 March 2012 - 13:10.

Harald Ponce de Leon

#7   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 March 2012 - 13:56

First step: Get your code working

/angry.png' class='bbc_emoticon' alt=':angry:' />
my code works ! ok ? so, avoid to be patronizing with me.
i just want to optimize my dev.
-------------------

#8   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 March 2012 - 18:04

Second step: Look where the core framework can be improved (to remove flexibility limits)
Third step: Propose changes to the core framework


I'm quite happy to participate in improvements , but i will not to do the work at your place.
My feeling is that, in this regard, I'm proceeding almost without any safety net, without documentation. Be aware of this.
The improvements and modifications on framework is your job.
Because it's your project, your future app store.
Please, do not switch roles.
/angry.png' class='bbc_emoticon' alt=':angry:' />
-------------------