<commit_before><?php
/*
 * This file is part of the sf-project-skeleton package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Core\Controller;

/**
 * Class BaseControllerTrait
 *
 * @package Core\Controller
 * @author <NAME> <<EMAIL>>
 */
trait BaseControllerTrait
{
    /**
     * get the template path for current bundle, controller and action
     *
     * @param string $method action name or namespace
     * @return string symfony formatted template path
     */
    protected function getTemplatePath($method = 'index')
    {
        /**
         * true for SF application bundle controllers
         * classpath always consists of:
         *
         * n namespace_base\
         * 1 BundleNameBundle\
         * 1 Controller\
         * 1 ControllerNameController\
         *********************************************************************/
        $classPath  = explode('\\', get_called_class());
        $controller = str_replace('Controller', '', array_pop($classPath));
        if (3 == count($classPath)) {
            $namespace = array_shift($classPath);
        } else {
            $namespace = '';
        }
        array_pop($classPath); // remove "Controller"
        $bundle = str_replace('Bundle', '', array_pop($classPath));

        // check if action is __METHOD__ or simple string
        if (0 < strpos($method, '::')) {
            // extract action
            $context = explode(
                '::',
                str_replace(<commit_msg>Fixed trait name<commit_after><?php
/*
 * This file is part of the sf-project-skeleton package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Core\Controller;

/**
 * Class BaseControllerTrait
 *
 * @package Core\Controller
 * @author <NAME> <<EMAIL>>
 */
trait TemplatePathTrait
{
    /**
     * get the template path for current bundle, controller and action
     *
     * @param string $method action name or namespace
     * @return string symfony formatted template path
     */
    public function getTemplatePath($method = 'index')
    {
        /**
         * true for SF application bundle controllers
         * classpath always consists of:
         *
         * n namespace_base\
         * 1 BundleNameBundle\
         * 1 Controller\
         * 1 ControllerNameController\
         *********************************************************************/
        $classPath  = explode('\\', get_called_class());
        $controller = str_replace('Controller', '', array_pop($classPath));
        if (3 == count($classPath)) {
            $namespace = array_shift($classPath);
        } else {
            $namespace = '';
        }
        array_pop($classPath); // remove "Controller"
        $bundle = str_replace('Bundle', '', array_pop($classPath));

        // check if action is __METHOD__ or simple string
        if (0 < strpos($method, '::')) {
            // extract action
            $context = explode(
                '::',
                str_replace(
{'fraction_non_alphanumeric': 0.1552369077306733, 'fraction_numerical': 0.003117206982543641, 'mean_word_length': 2.304840370751802, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, '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': '5551598', 'n_tokens_mistral': 817, 'n_tokens_neox': 795, 'n_words': 245}