<commit_before><?php

/**
 * Shopware 5
 * Copyright (c) shopware AG
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Shopware" is a registered trademark of shopware AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */

use Shopware\Models\Config\Element;
use Shopware\Models\Config\Form;
use Shopware\SwagCustomSort\Components\Sorting;
use Shopware\SwagCustomSort\Subscriber\Backend;
use Shopware\SwagCustomSort\Subscriber\ControllerPath;
use Shopware\SwagCustomSort\Subscriber\Frontend;
use Shopware\SwagCustomSort\Subscriber\Resource;
use Shopware\SwagCustomSort\Subscriber\Sort;
use Shopware\SwagCustomSort\Subscriber\StoreFrontBundle;

/**
 * Class Shopware_Plugins_Frontend_SwagCustomSort_Bootstrap
 */
class Shopware_Plugins_Frontend_SwagCustomSort_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /**
     * Returns the plugin label which is displayed in the plugin information and
     * in the Plugin Manager.
     *
     * @return string
     */
    public function getLabel()
    {
        return 'Individuelle Sortierung';
    }

    /**
     * Returns the version of the plugin as a string
     *
     * @return string|void
     * @throws Exception
     */
    public function getVersion()
    {
        $info = json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'plugin.json'), true);

        if ($info) {
            return $info['currentVersion'];
        } else {
            throw new Exception('The plugin has an invalid version file.');
        }
    }

    /**
     * Install Plugin / Add Events
     *
     * @return bool
     * @throws Exception
     */
    public function install()
    {
        if (!$this->assertVersionGreaterThen('5.0.0')) {
            throw new \Exception('This plugin requires Shopware 5.0.0 or a later version');
        }

        $this->subscribeEvents();
        $this->createDatabase();
        $this->createAttributes();
        $this->createMenu();
        $this->createForm($this->Form());

        return true;
    }

    /**
     * Standard plugin enable method
     *
     * @return array
     */
    public function enable()
    {
        $sql = "UPDATE s_core_menu SET active = 1 WHERE controller = 'CustomSort';";
        Shopware()->Db()->query($sql);

        return ['success' => true, 'invalidateCache' => ['backend']];
    }

    /**
     * Standard plugin disable method
     *
     * @return array
     */
    public function disable()
    {
        $sql = "UPDATE s_core_menu SET active = 0 WHERE controller = 'CustomSort';";
        Shopware()->Db()->query($sql);

        return ['success' => true, 'invalidateCache' => ['backend']];
    }

    /**
     * Registers all necessary events.
     */
    public function subscribeEvents()
    {
        $this->subscribeEvent('Enlight_Controller_Front_StartDispatch', 'onStartDispatch');
    }

    /**
     * Main entry point for the bonus system: Registers various subscribers to hook into shopware
     */
    public function onStartDispatch()
    {
        $container = Shopware()->Container();

        $resourceSubscriber = new Resource($this->get('models'));
        $this->Application()->Events()->addSubscriber($resourceSubscriber);

        /** @var Sorting $sortingComponent */
        $sortingComponent = $container->get('swagcustomsort.sorting_component');<commit_msg>PT-3828 fix bootstrap container service call<commit_after><?php

/**
 * Shopware 5
 * Copyright (c) shopware AG
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Shopware" is a registered trademark of shopware AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */

use Shopware\Models\Config\Element;
use Shopware\Models\Config\Form;
use Shopware\SwagCustomSort\Components\Sorting;
use Shopware\SwagCustomSort\Subscriber\Backend;
use Shopware\SwagCustomSort\Subscriber\ControllerPath;
use Shopware\SwagCustomSort\Subscriber\Frontend;
use Shopware\SwagCustomSort\Subscriber\Resource;
use Shopware\SwagCustomSort\Subscriber\Sort;
use Shopware\SwagCustomSort\Subscriber\StoreFrontBundle;

/**
 * Class Shopware_Plugins_Frontend_SwagCustomSort_Bootstrap
 */
class Shopware_Plugins_Frontend_SwagCustomSort_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /**
     * Returns the plugin label which is displayed in the plugin information and
     * in the Plugin Manager.
     *
     * @return string
     */
    public function getLabel()
    {
        return 'Individuelle Sortierung';
    }

    /**
     * Returns the version of the plugin as a string
     *
     * @return string|void
     * @throws Exception
     */
    public function getVersion()
    {
        $info = json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'plugin.json'), true);

        if ($info) {
            return $info['currentVersion'];
        } else {
            throw new Exception('The plugin has an invalid version file.');
        }
    }

    /**
     * Install Plugin / Add Events
     *
     * @return bool
     * @throws Exception
     */
    public function install()
    {
        if (!$this->assertVersionGreaterThen('5.0.0')) {
            throw new \Exception('This plugin requires Shopware 5.0.0 or a later version');
        }

        $this->subscribeEvents();
        $this->createDatabase();
        $this->createAttributes();
        $this->createMenu();
        $this->createForm($this->Form());

        return true;
    }

    /**
     * Standard plugin enable method
     *
     * @return array
     */
    public function enable()
    {
        $sql = "UPDATE s_core_menu SET active = 1 WHERE controller = 'CustomSort';";
        Shopware()->Db()->query($sql);

        return ['success' => true, 'invalidateCache' => ['backend']];
    }

    /**
     * Standard plugin disable method
     *
     * @return array
     */
    public function disable()
    {
        $sql = "UPDATE s_core_menu SET active = 0 WHERE controller = 'CustomSort';";
        Shopware()->Db()->query($sql);

        return ['success' => true, 'invalidateCache' => ['backend']];
    }

    /**
     * Registers all necessary events.
     */
    public function subscribeEvents()
    {
        $this->subscribeEvent('Enlight_Controller_Front_StartDispatch', 'onStartDispatch');
    }

    /**
     * Main entry point for the bonus system: Registers various subscribers to hook into shopware
     */
    public function onStartDispatch()
    {
        $container = $this->get('service_container');

        $resourceSubscriber = new Resource($this->get('models'));
        $this->Application()->Events()->addSubscriber($resourceSubscriber);

        /** @var Sorting $sortingComponent */
        $sortingComponent = $container->get('swagcustomsort.sorting_component');
{'fraction_non_alphanumeric': 0.10280947123052386, 'fraction_numerical': 0.003189792663476874, 'mean_word_length': 2.8948877209746775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, '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': '172695', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2148, 'n_words': 690}