简体   繁体   中英

Class extends classA, but has parent of classB… how?

Edit: Please disregard this quesion. This was a goof on my end: I was looking at one class (OpicControllerInsurance) and assuming it was another (OpicControllerInsurances). The only thing you have to learn from this question is that you need to doublecheck your input/output even when you think it's beyond question .

I have a class that inherits from JControllerAdmin (it's a joomla project, but it doesn't look like a joomla-specific problem):

jimport('joomla.application.component.controlleradmin');

/**
 * Insurance Type list controller class.
 *
 * @package     Joomla.Administrator
 * @subpackage  com_opic
 * @since       1.6
 */
class OpicControllerInsurances extends JControllerAdmin
{
...

And here's where an instance of the class is being created

// Instantiate the class.
   if (class_exists($class)) {
      // $class == 'OpicControllerInsurance', $config == ''
      $instance = new $class($config);         

      $test_class_name = get_class($instance); 
      // $test_class_name == OpicControllerInsurance

      $test_parent_class_name = get_parent_class($instance); 
      // $test_parent_class_name == JControllerForm
   }

Now, if OpicControllerInsurances extends JControllerAdmin how is it possible that it's parent class is JControllerForm?? This is one of those frustrating problems that seems to defy basic programming rules (which generally means that I simply don't understand the rules very well).

False alarm.

Of course; oop doesn't work that way. I was caught up by the Joomla MVC which has singular and plural names for each model (at least in this configuration). I didn't spot the difference between OpicControllerInsurances and OpicControllerInsurance in the debugger.

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