Trait rex_factory_trait

Factory trait.

Example child class:

class rex_example
{
    use rex_factory;

    private function __construct($param)
    {
        // ...
    }

    public static function factory($param)
    {
        $class = self::getFactoryClass();
        return new $class($param);
    }
}

Direct Known Users

rex_api_function, rex_backend_password_policy, rex_logger, rex_markdown, rex_navigation, rex_package_manager, rex_sql, rex_validator, rex_be_navigation, rex_config_form, rex_csrf_token, rex_editor, rex_extension, rex_finder, rex_form, rex_list

Indirect Known Users

rex_addon_manager, rex_api_article_move, rex_api_content_copy, rex_api_sitemap_tree, rex_plugin_manager

Package: redaxo\core
Author: gharlan
Located at redaxo/src/core/lib/base/factory_trait.php

Methods summary

public static
# setFactoryClass( string $subclass )

Sets the class for the factory.

public static string
# getFactoryClass( )

Returns the class for the factory.

public static boolean
# hasFactoryClass( )

Returns if the class has a custom factory class.

protected static mixed
# callFactoryClass( string $method, array $arguments )

Calls the factory class with the given method and arguments.