<commit_before><?php
/**
 * Description of TimetableManager
 *
 * @author vdegroote
 */
namespace CanalTP\MttBundle\Services;

use Doctrine\Common\Persistence\ObjectManager;
use CanalTP\MttBundle\Entity\Timetable;

class TimetableManager
{
    private $timetable = null;
    private $line = null;
    private $navitia = null;
    private $repository = null;
    private $om = null;

    public function __construct(ObjectManager $om, Navitia $navitia, LineManager $lineManager)
    {
        $this->timetable = null;
        $this->om = $om;
        $this->navitia = $navitia;
        $this->lineManager = $lineManager;
        $this->repository = $this->om->getRepository('CanalTPMttBundle:Timetable');
    }

    /*
     * @function find twig path for parent line
     */
    private function initAdditionalData($externalRouteId, $externalCoverageId)
    {
        $data = $this->navitia->getRouteData($externalRouteId, $externalCoverageId);
        $lineConfig = $this->timetable->getLineConfig();
        $this->lineManager->initTwigPath($lineConfig);

        $this->timetable->setTitle($data->direction->stop_point->name);
    }

    /*
     * get corresponding blocks and index them by dom_id
     */
    private function initBlocks()
    {
        $timetableBlocks = $this->repository->findBlocksByTimetableIdOnly($this->timetable->getId());

        if (count($timetableBlocks) > 0) {
            $blocks = array();

            foreach ($timetableBlocks as $block) {
                $blocks[$block->getDomId()] = $block;
            }
            if (count($blocks) > 0) {
                $this->timetable->setBlocks($blocks);
            }
        }
    }

    /**
     * Return timetable Object with navitia data added
     *
     * @param  Integer   $id PK in bdd
     * @return timetable
     */
    public function getTimetableById($timetableId, $externalCoverageId)
    {
        $this->timetable = $this->repository->find($timetableId);<commit_msg>Request for direction title in layouts updated. (now we use embedded_type)<commit_after><?php
/**
 * Description of TimetableManager
 *
 * @author vdegroote
 */
namespace CanalTP\MttBundle\Services;

use Doctrine\Common\Persistence\ObjectManager;
use CanalTP\MttBundle\Entity\Timetable;

class TimetableManager
{
    private $timetable = null;
    private $line = null;
    private $navitia = null;
    private $repository = null;
    private $om = null;

    public function __construct(ObjectManager $om, Navitia $navitia, LineManager $lineManager)
    {
        $this->timetable = null;
        $this->om = $om;
        $this->navitia = $navitia;
        $this->lineManager = $lineManager;
        $this->repository = $this->om->getRepository('CanalTPMttBundle:Timetable');
    }

    /*
     * @function find twig path for parent line
     */
    private function initAdditionalData($externalRouteId, $externalCoverageId)
    {
        $data = $this->navitia->getRouteData($externalRouteId, $externalCoverageId);
        $embedded_type = $data->direction->embedded_type;
        $lineConfig = $this->timetable->getLineConfig();
        $this->lineManager->initTwigPath($lineConfig);

        $this->timetable->setTitle($data->direction->$embedded_type->name);
    }

    /*
     * get corresponding blocks and index them by dom_id
     */
    private function initBlocks()
    {
        $timetableBlocks = $this->repository->findBlocksByTimetableIdOnly($this->timetable->getId());

        if (count($timetableBlocks) > 0) {
            $blocks = array();

            foreach ($timetableBlocks as $block) {
                $blocks[$block->getDomId()] = $block;
            }
            if (count($blocks) > 0) {
                $this->timetable->setBlocks($blocks);
            }
        }
    }

    /**
     * Return timetable Object with navitia data added
     *
     * @param  Integer   $id PK in bdd
     * @return timetable
     */
    public function getTimetableById($timetableId, $externalCoverageId)
    {
        $this->timetable = $this->repository->find($timetableId);
{'fraction_non_alphanumeric': 0.12731310140636565, 'fraction_numerical': 0.0009869232667160128, 'mean_word_length': 2.6754306436990025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, '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': '3194628', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1175, 'n_words': 239}