/*
@return Kwf_Component_Data
172659
public function getPageByUrl($url, $acceptLanguage, &$exactMatch = true)
    {
        $parsedUrl = parse_url($url);
        if (!isset($parsedUrl['path'])) return null;
        if (!isset($parsedUrl['host'])) {
            throw new Kwf_Exception("Host is missing in url '$url'");
        }
        foreach ($this->getPlugins('Kwf_Component_PluginRoot_Interface_PreResolveUrl') as $p) {
            $parsedUrl = $p->preFormatPath($parsedUrl);
        }
        $cacheUrl = $parsedUrl['host'].$parsedUrl['path'];
        if ($ret = Kwf_Component_Cache_Url_Abstract::getInstance()->load($cacheUrl)) {
            $exactMatch = true;
        } else {
            $path = $this->getComponent()->formatPath($parsedUrl);
            if (is_null($path)) return null;
            $baseUrl = Kwf_Setup::getBaseUrl();
            if ($baseUrl) {
                if (substr($path, 0, strlen($baseUrl)) != $baseUrl) {
                    return null;
                } else {
                    $path = substr($path, strlen($baseUrl));
                }
            }
            $path = trim($path, '/');
            $ret = $this->getComponent()->getPageByUrl($path, $acceptLanguage);

            if ($ret && (
                   $ret->generator->getGeneratorFlag('matchChildUrls')
                || rawurldecode($ret->url) == $parsedUrl['path']) //nur cachen wenn kein redirect gemacht wird
            ) {
                $exactMatch = true;
                if ($ret->isVisible()) {
                    Kwf_Component_Cache_Url_Abstract::getInstance()->save($cacheUrl, $ret);
                }
            } else {
                $exactMatch = false;
            }
        }
        return $ret;
    }
530893
public function getChildBoxes($select = array())
    {
        if (is_array($select)) {
            $select = new Kwf_Component_Select($select);
        } else {
            $select = clone $select;
        }
        $select->whereBox(true);
        return $this->getRecursiveChildComponents($select);
    }
965907
public function cleanAction()
    {
        set_time_limit(0);

        if (!$this->_getParam('id')) throw new Kwf_Exception_Client("required parameter --id");
        $db = Zend_Registry::get('db');
        $tables = array();
        foreach ($db->query("SHOW TABLES")->fetchAll() as $table) {
            $table = array_values($table);
            $table = $table[0];
            $hasComponentId = false;
            if ($table == 'kwf_pages') {
                $tables[] = $table;
            } else {
                foreach ($db->query("SHOW FIELDS FROM $table")->fetchAll() as $field) {
                    if ($field['Field'] == 'component_id') {
                        $tables[] = $table;
                    }
                }
            }
        }

        $ids = $this->_getChildIds($this->_getParam('id'));
        array_unshift($ids, $this->_getParam('id'));
        foreach ($ids as $id) {
            foreach ($tables as $table) {
                if ($table == 'kwf_pages') {
                    $column = 'id';
                } else {
                    $column = 'component_id';
                }
                $sql = "DELETE FROM $table ".
                    "WHERE $column='$id' ".
                       "OR $column LIKE '".str_replace('_', '\_', $id)."\_%' ".
                       "OR $column LIKE '".str_replace('_', '\_', $id)."-%'";
                echo $sql."\n";
                //echo ".";
                if ($this->_getParam('force')) $db->query($sql);
            }
        }
        if (!$this->_getParam('force')) echo "\nadd parameter --force to actually execute queries\n";
        exit;
    }
1355633
public function componentForced()
    {
        $function = function ($name = null, array $params = []) {

            if (is_null($name)) {
                return '';
            }
            $components = UIComponentsRegistry::get('ui-components', []);
            $component  = null;
            foreach ($components as $item) {
                if ($item->getSnakedName() === $name) {
                    $component = $item;
                    break;
                }
            }
            if (is_null($component)) {
                return '';
            }
            $this->gridStackAdapter->scripts();
            if (!empty($params)) {
                $component->setAttributes($params);
            }

            $classname = 'Antares\UI\UIComponents\Templates\Datatables';
            $view      = ($component instanceof $classname) ? 'antares/ui-components::admin.partials._forced_datatable' : 'antares/ui-components::admin.partials._forced';

            $component->setView($view);
            return $component;
        };

        return new Twig_SimpleFunction(
                'component_forced', $function
        );
    }
1179984
protected function _getComponentId($select)
    {
        $componentId = null;
        if ($select) {
            if ($select->getPart(Kwf_Model_Select::WHERE_EQUALS)) {
                foreach ($select->getPart(Kwf_Model_Select::WHERE_EQUALS) as $k=>$i) {
                    if ($k == 'component_id') $componentId = $i;
                }
            }
        }
        return $componentId;
    }
501719
private function _getProductsData(Kwf_Component_Data $subroot = null)
    {
        $ret = array();

        $items = $this->getChildRows('Products');
        $ret = array();

        foreach ($items as $i) {
            $data = Kwc_Shop_VoucherProduct_AddToCart_OrderProductData::getInstance($i->add_component_class);
            $r = array(
                'id' => $i->id,
                'additionalOrderData' => $data->getAdditionalOrderData($i),
                'price' => $this->_getProductPrice($i),
                'amount' => $data->getAmount($i),
                'text' => $data->getProductText($i),
            );
            if ($subroot) {
                $addComponent = Kwc_Shop_AddToCartAbstract_OrderProductData::getAddComponentByDbId(
                    $i->add_component_id, $subroot
                );
                if (!$addComponent) {
                    //product doesn't exist anymore, also delete from cart
                    $i->delete();
                    continue;
                } else {
                    $r['product'] = $addComponent->parent;
                    $r['text'] = $addComponent->getComponent()->getProductText($i);
                }
            }
            $ret[] = (object)$r;
        }
        return $ret;
    }
712326
public static function getInstance()
    {
        if (is_null(self::$_instance)) {
            $c = self::getComponentClass();
            if ($c) {
                self::$_instance = new self(array('componentClass' => $c));
            } else {
                self::$_instance = false;
            }
        }
        return self::$_instance;
    }
327853
protected function getMainComponentInfo() {
    // Scanning for components and parsing their info is expensive, so cache it.
    if ($this->componentInfo === NULL) {
      $components = $this->componentDiscovery->getMainComponents();

      // Couldn't figure out how to sort the components with a uasort(). Went
      // with the quick and dirty way instead. Don't judge me!
      Element::order($components, [
        'lightning_core',
        'lightning_media',
        'lightning_layout',
        'lightning_workflow',
        'lightning_preview',
      ]);

      $this->componentInfo = array_map(
        function (Extension $component) {
          return $this->infoParser->parse($component->getPathname());
        },
        $components
      );
    }
    return $this->componentInfo;
  }
388798
public function data()
    {
        $args = func_get_args();

        if (isset($args[0]) && is_array($args[0])) {
            $this->data = array_merge($this->data, array_change_key_case($args[0]));

            // Cascade data to item's children if cascade_data option is enabled
            if ($this->builder->conf['cascade_data']) {
                $this->cascade_data($args);
            }

            return $this;
        } elseif (isset($args[0]) && isset($args[1])) {
            $this->data[strtolower($args[0])] = $args[1];

            // Cascade data to item's children if cascade_data option is enabled
            if ($this->builder->conf['cascade_data']) {
                $this->cascade_data($args);
            }

            return $this;
        } elseif (isset($args[0])) {
            return isset($this->data[$args[0]]) ? $this->data[$args[0]] : null;
        }

        return $this->data;
    }
1023113
public function getData()
    {
        $connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
        $result = $connection->fetchAll('SELECT id, plan_name FROM `cko_m2_plans`');

        return $this->formatData($result);
    }
671378
public function getImageUrl()
    {
        $baseUrl = $this->getBaseImageUrl();
        if ($baseUrl) {
            $dimensions = $this->getImageDimensions();
            $imageData = $this->getImageData();
            $width = Kwf_Media_Image::getResponsiveWidthStep($dimensions['width'],
                    Kwf_Media_Image::getResponsiveWidthSteps($dimensions, $imageData['file']));
            $ret = str_replace('{width}', $width, $baseUrl);
            $ev = new Kwf_Component_Event_CreateMediaUrl($this->getData()->componentClass, $this->getData(), $ret);
            Kwf_Events_Dispatcher::fireEvent($ev);
            return $ev->url;
        }
        return null;
    }
1172822
public function getImageDimensions()
    {
        $dimension = $this->getData()->chained->getComponent()->_getSetting('dimension');
        if ($this->getData()->chained->getComponent()->getRow()->use_crop) {
            $parentDimensions = $this->_getImageEnlargeComponent()->getImageDimensions();
            $dimension['crop'] = $parentDimensions['crop'];
        }
        $data = $this->getImageData();
        return Kwf_Media_Image::calculateScaleDimensions($data['file'], $dimension);
    }
520527
public function getTemplate(Kwf_Component_Data $component, $type)
    {
        if ($type == 'Master') {
            if (Kwc_Abstract::hasSetting($component->componentClass, 'masterTemplate')) {
                return Kwc_Abstract::getSetting($component->componentClass, 'masterTemplate');
            }
        }
        $template = Kwc_Abstract::getTemplateFile($component->componentClass, $type);
        if (!$template) throw new Kwf_Exception("No $type-Template found for '{$component->componentClass}'");
        return $template;
    }
782790
public function getDataForm()
    {
        $data = null;
        foreach ($this->dicionario as $meta)
            $data[$meta->getColumn()] = $meta->getValue();

        return $data;
    }
1307834
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
    {
        $ret = array();
        $ret['placeholder'] = $this->_getPlaceholder();
        $ret['rootElementClass'] = self::getRootElementClass($this);
        $ret['bemClass'] = $this->_getBemClass('');

        $ret['data'] = $this->getData();
        $ret['row'] = $this->_getRow();

        $supportedContexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getSupportedContexts();
        if ($supportedContexts) {
            $contexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getContexts($this->getData());
            if (is_null($contexts)) {
                $e = new Kwf_Exception("Didn't get layout contexts for ".$this->getData()->componentId);
                $e->logOrThrow();
            }
            foreach ($contexts as $ctx) {
                if (!in_array($ctx, $supportedContexts)) {
                    $e = new Kwf_Exception("Master Layout Context ".json_encode($ctx)." is not supported by ".$this->getData()->componentClass." for '".$this->getData()->componentId."'");
                    $e->logOrThrow();
                }
            }
        }
        return $ret;
    }
159737
public function getComponentsByDbId($dbId, $select = array())
    {
        if (is_array($select)) {
            $select = new Kwf_Component_Select($select);
        }

        $cacheId = $dbId.$select->getHash();
        if (!isset($this->_componentsByDbIdCache[$cacheId])) {

            if (is_numeric(substr($dbId, 0, 1)) || substr($dbId, 0, 4)=='root') {
                $data = $this->getComponentById($dbId, $select);
                if ($data) {
                    return array($data);
                } else {
                    return array();
                }
            }

            if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
                $limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
            }
            $ret = array();
            foreach (Kwc_Abstract::getComponentClasses() as $class) {
                foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
                    if (isset($generator['dbIdShortcut'])
                            && substr($dbId, 0, strlen($generator['dbIdShortcut'])) == $generator['dbIdShortcut']) {
                        $idParts = $this->_getIdParts(substr($dbId, strlen($generator['dbIdShortcut']) - 1));
                        $generator = Kwf_Component_Generator_Abstract::getInstance($class, $key);
                        if (count($idParts) <= 1) {
                            $generatorSelect = clone $select;
                        } else {
                            $generatorSelect = new Kwf_Component_Select(); // Select erst bei letzten Part
                            if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
                                $generatorSelect->ignoreVisible($select->getPart(Kwf_Component_Select::IGNORE_VISIBLE));
                            }
                            if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
                                $generatorSelect->whereSubroot($select->getPart(Kwf_Component_Select::WHERE_SUBROOT));
                            }
                        }
                        if (isset($limitCount)) {
                            $generatorSelect->limit($limitCount - count($ret));
                        }
                        $generatorSelect->whereId($idParts[0]);
                        $data = $generator->getChildData(null, $generatorSelect);
                        unset($idParts[0]);
                        foreach ($data as $d) {
                            $componentId = $d->componentId . implode('', $idParts);
                            $data = $this->getComponentById($componentId, $select);
                            if ($data) {
                                $ret[] = $data;
                            }
                            if (isset($limitCount) && $limitCount - count($ret) <= 0) {
                                break 3;
                            }
                        }
                    }
                }
            }
            $this->_componentsByDbIdCache[$cacheId] = $ret;
        }
        return $this->_componentsByDbIdCache[$cacheId];
    }
1281480
protected function getComponentFromResolvedComponentData(ResolvedComponentData $resolved)
    {
        /** @var $component ComponentInterface */
        $component = new $this->componentClass();
        $component->setModel($resolved->getModel());
        $component->setData($resolved->getData());
        $component->setIdentifier($resolved->getIdentifier());

        return $component;
    }