<commit_before><?php
/*
 * This file is part of the Sulu CMS.
 *
 * (c) MASSIVE ART WebServices GmbH
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sulu\Bundle\ProductBundle\Controller;

use Sulu\Bundle\ProductBundle\Api\Status;
use Sulu\Bundle\ProductBundle\Api\TaxClass;
use Sulu\Bundle\ProductBundle\Entity\Currency;
use Symfony\Component\HttpFoundation\Request;
use Sulu\Component\Rest\RestController;
use Sulu\Bundle\ProductBundle\Api\Attribute as ApiAttribute;

class TemplateController extends RestController
{
    /**
     * Returns Template for product list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productListAction()
    {
        return $this->render('SuluProductBundle:Template:product.list.html.twig');
    }

    /**
     * Returns Template for product list
     *
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productFormAction(Request $request)
    {
        $language = $this->getLocale($request);

        $status = $this->getStatus($language);
        $units = $this->getUnits($language);
        $deliveryStates = $this->getDeliveryStates($language);

        return $this->render(
            'SuluProductBundle:Template:product.form.html.twig',
            array(
                'status' => $status,
                'units' => $units,
                'deliveryStates' => $deliveryStates
            )
        );
    }

    public function productVariantsAction()
    {
        return $this->render('SuluProductBundle:Template:product.variants.html.twig');
    }

    /**
     * Returns Template for product import
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productImportAction()
    {
        return $this->render(
            'SuluProductBundle:Template:product.import.html.twig'
        );
    }

    /**
     * Returns Template for attribute list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function attributeListAction()
    {
        return $this->render(
            'SuluProductBundle:Template:attribute.list.html.twig'
        );
    }

    /**
     * Returns Template for attribute list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function attributeFormAction()
    {
        $repository = $this->getDoctrine()
            ->getRepository('SuluProductBundle:AttributeType');
        $types = $repository->findAll();

        $attributeTypes = array();
        foreach ($types as $type) {
            $attributeTypes[] = array(
                'id' => $type->getId(),
                'name' => $type->getName()
            );
        }

        return $this->render(
            'SuluProductBundle:Template:attribute.form.html.twig',
            array(
                'attribute_types' => $attributeTypes
            )
        );
    }

    /**
     * Returns Template for product pricing
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productPricingAction()
    {
        // TODO use correct language
        $language = 'en';

        /** @var TaxClass[] $taxClasses */
        $taxClasses = $this->get('sulu_product.tax_class_manager')->findAll($language);

        $taxClassTitles = array();
        foreach ($taxClasses as $taxClass) {
            $taxClassTitles[] = array(
                'id' => $taxClass->getId(),
                'name' => $taxClass->getName()
            );
        }

        $currencies = $this->getCurrencies($language);
        $defaultCurrency = $this->container->getParameter('sulu_product.default_currency');

        return $this->render(
            'SuluProductBundle:Template:product.pricing.html.twig',
            array(
                'taxClasses' => $taxClassTitles,
                'currencies' => $currencies,
                'defaultCurrency' => $defaultCurrency
            )
        );
    }

    /**
     * Returns the template for product documents
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productDocumentsAction()
    {
        return $this->render('SuluProductBundle:Template:product.documents.html.twig');
    }

    /**
     * Returns the template for product attributes
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productAttributesAction()
    {
        return $this->render('SuluProductBundle:Template:product.attributes.html.twig');
    }

    /**
     * Returns status for products
     *
     * @param string $language
     *
     * @return array
     */
    protected function getStatus($language)
    {
        /** @var Status[] $statuses */
        $statuses = $this->get('sulu_product.status_manager')->findAll($language);

        $statusTitles = array();
        foreach ($statuses as $status) {
            $statusTitles[] = array(
                'id' => $status->getId(),
                'name' => $status->getName()
            );
        }

        return $statusTitles;
    }

    /**
     * Returns units
     *
     * @param string $language
     *
     * @return array
     */
    protected function getUnits($language)
    {
        /** @var Status[] $units */
        $units = $this->get('sulu_product.unit_manager')->findAll($language);

        $unitTitles = array();
        foreach ($units as $unit) {
            $unitTitles[] = array(
                'id' => $unit->getId(),
                'name' => $unit->getName()
            );
        }

        return $unitTitles;
    }

    /**
     * Returns currencies
     *
     * @param string $language
     *
     * @return array
     */
    protected function getCurrencies($language)
    {
        /** @var Currency[] $currencies */
        $currencies = $this->get('sulu_product.currency_manager')->findAll($language);

        $currencyTitles = array();
        foreach ($currencies as $currency) {
            $currencyTitles[] = array(
                'id' => $currency->getId(),
                'name' => $currency->getName(),
                'code' => $currency->getCode(),
                'number' => $currency->getNumber()
            );
        }

        return $currencyTitles;
    }

    /**
     * Returns delivery states
     *
     * @param string $language
     *
     * @return array
     */
    protected function getDeliveryStates($language)
    {
        $states = $this->getDeliveryStatusManager()->findAll($language);

        $deliveryStates = array();
        foreach ($states as $state) {
            $deliveryStates[] = array(
                'id' => $state->getId(),
                'name' => $state->getName()
            );
        }

        return $deliveryStates;
    }

    /**
     * Returns the delivery status manager
     *
     * @return DeliveryStatusManager
     */
    private function getDeliveryStatusManager()
    {
        return $this->get('sulu_product.delivery_status_manager');
    }
}
<commit_msg>translations for tax rate fix<commit_after><?php
/*
 * This file is part of the Sulu CMS.
 *
 * (c) MASSIVE ART WebServices GmbH
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sulu\Bundle\ProductBundle\Controller;

use Sulu\Bundle\ProductBundle\Api\Status;
use Sulu\Bundle\ProductBundle\Api\TaxClass;
use Sulu\Bundle\ProductBundle\Entity\Currency;
use Symfony\Component\HttpFoundation\Request;
use Sulu\Component\Rest\RestController;
use Sulu\Bundle\ProductBundle\Api\Attribute as ApiAttribute;

class TemplateController extends RestController
{
    /**
     * Returns Template for product list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productListAction()
    {
        return $this->render('SuluProductBundle:Template:product.list.html.twig');
    }

    /**
     * Returns Template for product list
     *
     * @param \Symfony\Component\HttpFoundation\Request $request
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productFormAction(Request $request)
    {
        $language = $this->getLocale($request);

        $status = $this->getStatus($language);
        $units = $this->getUnits($language);
        $deliveryStates = $this->getDeliveryStates($language);

        return $this->render(
            'SuluProductBundle:Template:product.form.html.twig',
            array(
                'status' => $status,
                'units' => $units,
                'deliveryStates' => $deliveryStates
            )
        );
    }

    public function productVariantsAction()
    {
        return $this->render('SuluProductBundle:Template:product.variants.html.twig');
    }

    /**
     * Returns Template for product import
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productImportAction()
    {
        return $this->render(
            'SuluProductBundle:Template:product.import.html.twig'
        );
    }

    /**
     * Returns Template for attribute list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function attributeListAction()
    {
        return $this->render(
            'SuluProductBundle:Template:attribute.list.html.twig'
        );
    }

    /**
     * Returns Template for attribute list
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function attributeFormAction()
    {
        $repository = $this->getDoctrine()
            ->getRepository('SuluProductBundle:AttributeType');
        $types = $repository->findAll();

        $attributeTypes = array();
        foreach ($types as $type) {
            $attributeTypes[] = array(
                'id' => $type->getId(),
                'name' => $type->getName()
            );
        }

        return $this->render(
            'SuluProductBundle:Template:attribute.form.html.twig',
            array(
                'attribute_types' => $attributeTypes
            )
        );
    }

    /**
     * Returns Template for product pricing
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productPricingAction(Request $request)
    {
        // TODO use correct language
        $language = $this->getLocale($request);

        /** @var TaxClass[] $taxClasses */
        $taxClasses = $this->get('sulu_product.tax_class_manager')->findAll($language);

        $taxClassTitles = array();
        foreach ($taxClasses as $taxClass) {
            $taxClassTitles[] = array(
                'id' => $taxClass->getId(),
                'name' => $taxClass->getName()
            );
        }

        $currencies = $this->getCurrencies($language);
        $defaultCurrency = $this->container->getParameter('sulu_product.default_currency');

        return $this->render(
            'SuluProductBundle:Template:product.pricing.html.twig',
            array(
                'taxClasses' => $taxClassTitles,
                'currencies' => $currencies,
                'defaultCurrency' => $defaultCurrency
            )
        );
    }

    /**
     * Returns the template for product documents
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productDocumentsAction()
    {
        return $this->render('SuluProductBundle:Template:product.documents.html.twig');
    }

    /**
     * Returns the template for product attributes
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function productAttributesAction()
    {
        return $this->render('SuluProductBundle:Template:product.attributes.html.twig');
    }

    /**
     * Returns status for products
     *
     * @param string $language
     *
     * @return array
     */
    protected function getStatus($language)
    {
        /** @var Status[] $statuses */
        $statuses = $this->get('sulu_product.status_manager')->findAll($language);

        $statusTitles = array();
        foreach ($statuses as $status) {
            $statusTitles[] = array(
                'id' => $status->getId(),
                'name' => $status->getName()
            );
        }

        return $statusTitles;
    }

    /**
     * Returns units
     *
     * @param string $language
     *
     * @return array
     */
    protected function getUnits($language)
    {
        /** @var Status[] $units */
        $units = $this->get('sulu_product.unit_manager')->findAll($language);

        $unitTitles = array();
        foreach ($units as $unit) {
            $unitTitles[] = array(
                'id' => $unit->getId(),
                'name' => $unit->getName()
            );
        }

        return $unitTitles;
    }

    /**
     * Returns currencies
     *
     * @param string $language
     *
     * @return array
     */
    protected function getCurrencies($language)
    {
        /** @var Currency[] $currencies */
        $currencies = $this->get('sulu_product.currency_manager')->findAll($language);

        $currencyTitles = array();
        foreach ($currencies as $currency) {
            $currencyTitles[] = array(
                'id' => $currency->getId(),
                'name' => $currency->getName(),
                'code' => $currency->getCode(),
                'number' => $currency->getNumber()
            );
        }

        return $currencyTitles;
    }

    /**
     * Returns delivery states
     *
     * @param string $language
     *
     * @return array
     */
    protected function getDeliveryStates($language)
    {
        $states = $this->getDeliveryStatusManager()->findAll($language);

        $deliveryStates = array();
        foreach ($states as $state) {
            $deliveryStates[] = array(
                'id' => $state->getId(),
                'name' => $state->getName()
            );
        }

        return $deliveryStates;
    }

    /**
     * Returns the delivery status manager
     *
     * @return DeliveryStatusManager
     */
    private function getDeliveryStatusManager()
    {
        return $this->get('sulu_product.delivery_status_manager');
    }
}

{'fraction_non_alphanumeric': 0.12763433356594556, 'fraction_numerical': 0.0, 'mean_word_length': 2.0050325015726567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 134, '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': '3289431', 'n_tokens_mistral': 3971, 'n_tokens_neox': 3866, 'n_words': 739}