<commit_before><?php
abstract class Vps_Component_Abstract_ExtConfig_Abstract
{
    const TYPE_DEFAULT = 'default';
    const TYPE_SHARED = 'shared';

    protected $_class;

    public function __construct($componentClass)
    {
        $this->_class = $componentClass;
    }

    /**
     * @return $this
     */
    public static function getInstance($componentClass)
    {
        static $instances = array();
        if (!isset($instances[$componentClass])) {
            $c = Vpc_Abstract::getSetting($componentClass, 'extConfig');
            if (!$c) throw new Vps_Exception("extConfig not set");
            $instances[$componentClass] = new $c($componentClass);
        }
        return $instances[$componentClass];
    }


    protected final function _getSetting($name)
    {
        return Vpc_Abstract::getSetting($this->_class, $name);
    }

    //TODO code hierher verschieben
    public function getControllerUrl($class = 'Index')
    {
        return Vpc_Admin::getInstance($this->_class)->getControllerUrl($class);
    }

    protected final function _getAdmin()
    {
        return Vpc_Admin::getInstance($this->_class);
    }

    public final function getConfig($type)
    {
        if ($type == self::TYPE_SHARED) {
            if (Vpc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
                return $this->_getConfig();
            }
        } else {
            if (!Vpc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
                return $this->_getConfig();
            }
        }
        return array();
    }

    abstract protected function _getConfig();

    protected final function _getStandardConfig($xtype, $controllerName = 'Index', $title = null, $icon = null)
    {
        if (!$title) {
            if (!Vpc_Abstract::hasSetting($this->_class, 'componentName')
                || !Vpc_Abstract::getSetting($this->_class, 'componentName'))
            {
                throw new Vps_Exception("Component '$this->_class' does have no componentName but must have one for editing");
            }

            $title = trlVps('Edit {0}', $this->_getSetting('componentName'));
        }

        if (!$icon) $icon = $this->_getSetting('componentIcon');
        if ($icon instanceof Vps_Asset) $icon = $icon->__toString();
        $ret = array(
            'xtype' => $xtype,
            'title' => $title,
            'icon' => $icon
        );
        if ($controllerName) {
            $ret['controllerUrl'] = $this->getControllerUrl($controllerName);
        }<commit_msg>bearbeiten das an zig stellen angezeigt wurde entfernt<commit_after><?php
abstract class Vps_Component_Abstract_ExtConfig_Abstract
{
    const TYPE_DEFAULT = 'default';
    const TYPE_SHARED = 'shared';

    protected $_class;

    public function __construct($componentClass)
    {
        $this->_class = $componentClass;
    }

    /**
     * @return $this
     */
    public static function getInstance($componentClass)
    {
        static $instances = array();
        if (!isset($instances[$componentClass])) {
            $c = Vpc_Abstract::getSetting($componentClass, 'extConfig');
            if (!$c) throw new Vps_Exception("extConfig not set");
            $instances[$componentClass] = new $c($componentClass);
        }
        return $instances[$componentClass];
    }


    protected final function _getSetting($name)
    {
        return Vpc_Abstract::getSetting($this->_class, $name);
    }

    //TODO code hierher verschieben
    public function getControllerUrl($class = 'Index')
    {
        return Vpc_Admin::getInstance($this->_class)->getControllerUrl($class);
    }

    protected final function _getAdmin()
    {
        return Vpc_Admin::getInstance($this->_class);
    }

    public final function getConfig($type)
    {
        if ($type == self::TYPE_SHARED) {
            if (Vpc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
                return $this->_getConfig();
            }
        } else {
            if (!Vpc_Abstract::getFlag($this->_class, 'sharedDataClass')) {
                return $this->_getConfig();
            }
        }
        return array();
    }

    abstract protected function _getConfig();

    protected final function _getStandardConfig($xtype, $controllerName = 'Index', $title = null, $icon = null)
    {
        if (!$title) {
            if (!Vpc_Abstract::hasSetting($this->_class, 'componentName')
                || !Vpc_Abstract::getSetting($this->_class, 'componentName'))
            {
                throw new Vps_Exception("Component '$this->_class' does have no componentName but must have one for editing");
            }
            $title = $this->_getSetting('componentName');
            if (strpos($title, '.') !== false) $title = substr(strrchr($title, '.'), 1);
        }

        if (!$icon) $icon = $this->_getSetting('componentIcon');
        if ($icon instanceof Vps_Asset) $icon = $icon->__toString();
        $ret = array(
            'xtype' => $xtype,
            'title' => $title,
            'icon' => $icon
        );
        if ($controllerName) {
            $ret['controllerUrl'] = $this->getControllerUrl($controllerName);
        }
{'fraction_non_alphanumeric': 0.1365477338476374, 'fraction_numerical': 0.0003857280617164899, 'mean_word_length': 2.391759319816874, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3391246', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1405, 'n_words': 305}