<commit_before><?php

namespace OpenOrchestra\ApiBundle\Transformer;

use OpenOrchestra\ApiBundle\Exceptions\TransformerParameterTypeException;
use OpenOrchestra\ApiBundle\Facade\TemplateFacade;
use OpenOrchestra\Backoffice\NavigationPanel\Strategies\TreeTemplatePanelStrategy;
use OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer;
use OpenOrchestra\ModelInterface\Model\TemplateInterface;

/**
 * Class TemplateTransformer
 */
class TemplateTransformer extends AbstractSecurityCheckerAwareTransformer
{
    /**
     * @param TemplateInterface $template
     *
     * @return TemplateFacade
     *
     * @throws TransformerParameterTypeException
     */
    public function transform($template)
    {
        if (!$template instanceof TemplateInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = new TemplateFacade();
        foreach ($template->getAreas() as $area) {
            $facade->addArea($this->getTransformer('area')->transformFromTemplate($area, $template));
        }

        $facade->id = $template->getId();
        $facade->name = $template->getName();
        $facade->siteId = $template->getSiteId();
        $facade->templateId = $template->getTemplateId();
        $facade->language = $template->getLanguage();
        $facade->deleted = $template->isDeleted();
        $facade->boDirection = $template->getBoDirection();

        $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_template_form',
            array('templateId' => $template->getTemplateId())
        ));

        if ($this->authorizationChecker->isGranted(TreeTemplatePanelStrategy::ROLE_ACCESS_DELETE_TEMPLATE)) {
            $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_template_delete',
                array('templateId' => $template->getTemplateId())
            ));
        }

        if ($this->authorizationChecker->isGranted(TreeTemplatePanelStrategy::ROLE_ACCESS_UPDATE_TEMPLATE)) {
            $facade->addLink('_self_update_areas', $this->generateRoute('open_orchestra_api_areas_update_in_template',
                array(
                    'templateId' => $template->getTemplateId())
            ));
        }

        return $facade;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'template';
    }
<commit_msg>isGranted update<commit_after><?php

namespace OpenOrchestra\ApiBundle\Transformer;

use OpenOrchestra\ApiBundle\Exceptions\TransformerParameterTypeException;
use OpenOrchestra\ApiBundle\Facade\TemplateFacade;
use OpenOrchestra\Backoffice\NavigationPanel\Strategies\TreeTemplatePanelStrategy;
use OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer;
use OpenOrchestra\ModelInterface\Model\TemplateInterface;

/**
 * Class TemplateTransformer
 */
class TemplateTransformer extends AbstractSecurityCheckerAwareTransformer
{
    /**
     * @param TemplateInterface $template
     *
     * @return TemplateFacade
     *
     * @throws TransformerParameterTypeException
     */
    public function transform($template)
    {
        if (!$template instanceof TemplateInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = new TemplateFacade();
        foreach ($template->getAreas() as $area) {
            $facade->addArea($this->getTransformer('area')->transformFromTemplate($area, $template));
        }

        $facade->id = $template->getId();
        $facade->name = $template->getName();
        $facade->siteId = $template->getSiteId();
        $facade->templateId = $template->getTemplateId();
        $facade->language = $template->getLanguage();
        $facade->deleted = $template->isDeleted();
        $facade->boDirection = $template->getBoDirection();

        $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_template_form',
            array('templateId' => $template->getTemplateId())
        ));

        if ($this->authorizationChecker->isGranted(TreeTemplatePanelStrategy::ROLE_ACCESS_DELETE_TEMPLATE, $template)) {
            $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_template_delete',
                array('templateId' => $template->getTemplateId())
            ));
        }

        if ($this->authorizationChecker->isGranted(TreeTemplatePanelStrategy::ROLE_ACCESS_UPDATE_TEMPLATE, $template)) {
            $facade->addLink('_self_update_areas', $this->generateRoute('open_orchestra_api_areas_update_in_template',
                array(
                    'templateId' => $template->getTemplateId())
            ));
        }

        return $facade;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'template';
    }

{'fraction_non_alphanumeric': 0.12331326551795724, 'fraction_numerical': 0.0, 'mean_word_length': 3.286476868327402, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, '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': '2357856', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1321, 'n_words': 173}