<commit_before><?php

/*
 * This file is part of the OverblogThriftBundle package.
 *
 * (c) Overblog <http://github.com/overblog/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Overblog\ThriftBundle\Routing;

use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

class ThriftRoutingLoader extends Loader
{
    protected $services;

    public function __construct($services)
    {
        $this->services = $services;
    }

    /**
     * Loads a resource.
     *
     * @param mixed       $resource The resource
     * @param string|null $type     The resource type or null if unknown
     *
     * @throws \Exception If something went wrong
     */
    public function load($resource, $type = null)
    {
        $coll = new RouteCollection();
        foreach ($this->services as $path => $service) {
            $route = new Route(
                '/'.$path,
                ['_controller' => 'ThriftBundle:Thrift:server', 'extensionName' => $path],
                [],
                [],
                null,
                [],
                ['post']
            );
            $coll->add('thrift.'.$service['service'], $route);
        }

        return $coll;
    }

    /**<commit_msg>bugfix; Annotations 'ThriftBundle:Thrift:server' no longer work for Symfony 4 when passing '_controller'. Passing 'Overblog\ThriftBundle\Controller\ThriftController::serverAction' instead<commit_after><?php

/*
 * This file is part of the OverblogThriftBundle package.
 *
 * (c) Overblog <http://github.com/overblog/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Overblog\ThriftBundle\Routing;

use App\Kernel;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

class ThriftRoutingLoader extends Loader
{
    protected $services;

    public function __construct($services)
    {
        $this->services = $services;
    }

    /**
     * Loads a resource.
     *
     * @param mixed $resource The resource
     * @param string|null $type The resource type or null if unknown
     *
     * @return RouteCollection
     * @throws \Exception If something went wrong
     */
    public function load($resource, $type = null)
    {
        $controllerArg = Kernel::VERSION_ID > 40000 ?
            'Overblog\ThriftBundle\Controller\ThriftController::serverAction' :
            'ThriftBundle:Thrift:server';

        $coll = new RouteCollection();
        foreach ($this->services as $path => $service) {
            $route = new Route(
                '/'.$path,
                ['_controller' => $controllerArg, 'extensionName' => $path],
                [],
                [],
                null,
                [],
                ['post']
            );
            $coll->add('thrift.'.$service['service'], $route);
        }

        return $coll;
    }

    /**
{'fraction_non_alphanumeric': 0.11698717948717949, 'fraction_numerical': 0.0019230769230769232, 'mean_word_length': 2.220846233230134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '7034691', 'n_tokens_mistral': 846, 'n_tokens_neox': 837, 'n_words': 225}