Call a class extension within the mother class?

Asked

Viewed 60 times

1

I work with a kind of framework for HTML rendering and events, among other essential things, which is actually a standard HTML code generator because I can use either as a direct renderer or as an add-on to standardize my HTML.

Within this framework I have a class to include the dependencies to make it work properly, and, I can extend this class to include other dependencies that are not part of the framework.

Currently, the working mode is a 'play back and forth again', that would be, store the whole page in a variable, and through the DOM add the new dependencies giving a merge between the arrays framework default and extension add-ons.

//Dentro de $page está todo html da página
$page = $VIDB->content($form)->container('fluid')->go('pt-br');

echo \geralComponents\extendsLocal__jsPackages::get_extendeds_packages($page);

Method get_extends_packages()

public static function get_extendeds_packages($page)
    {
        $extra_packages = self::plus_packages();
        include 'vendor/vidb/assets/php/phpQuery-onefile.php';
        $doc = \phpQuery::newDocument($page);
        $packages = self::get_packages($extra_packages);
        return $doc->find('#js-packages-content')->html($packages);
    }

And the get_packages method

public static function get_packages($extra)
    {
        $files = '';
        $packages = self::packages();
        if($extra != null){
            $packages = array_merge($packages,$extra);
        }
        foreach ($packages as $import)
        {
            $path = $import['path'];
            $file = $import['file'];
            $version = $import['version'];
            $files .= '<script src="' . $path . '/' . $file . '' . $version . '.js"></script>';
        }
        return $files;
    }

Knowing that it may be necessary to include dependencies that are not foreseen in the framework, I could create an extension for the class within the application that is being developed to include this dependency. The doubt I have in relation to this process is as follows:

It is possible to have a mother class method check if it exists an extension for the class, and if it exists, perform some method of that class extension?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.