<commit_before><?php

/**
 * UserManager service for user related needs
 *
 * @author vdegroote
 */
namespace CanalTP\MttBundle\Services;

use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;

class UserManager
{
    private $om = null;
    private $translator = null;
    private $container = null;

    public function __construct(
        ObjectManager $om,
        Translator $translator,
        $container
    )
    {
        $this->om = $om;
        $this->translator = $translator;
        $this->container = $container;
    }

    /**
     * Retrieve current user networks
     */
    public function getNetworks($user = null)
    {
        $networks = $this->om
            ->getRepository('CanalTPMttBundle:Network')
            ->findNetworksByUserId(
                ($user != null) ? $user->getId() : $this->container->get('security.context')->getToken()->getUser()->getId()
            );

        if (count($networks) == 0) {
            throw new \Exception(
                $this->translator->trans(
                    'controller.default.navigation.no_networks',
                    array(),
                    'exceptions'
                )
            );
        }

        return $networks;
    }
}<commit_msg>Refs #302 ~ Configuration updated for all plateforms<commit_after><?php

/**
 * UserManager service for user related needs
 *
 * @author vdegroote
 */
namespace CanalTP\MttBundle\Services;

use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;

class UserManager
{
    private $om = null;
    private $translator = null;
    private $container = null;

    public function __construct(
        ObjectManager $om,
        Translator $translator,
        $container
    )
    {
        $this->om = $om;
        $this->translator = $translator;
        $this->container = $container;
    }

    /**
     * Retrieve current user networks
     */
    public function getNetworks($user = null)
    {
        if ($user == null) {
            $user = $this->container->get('security.context')->getToken()->getUser();
        }
        if ($user === 'anon.') {
            return (array());
        }
        $networks = $this->om
            ->getRepository('CanalTPMttBundle:Network')
            ->findNetworksByUserId(
                $user->getId()
            );

        if (count($networks) == 0) {
            throw new \Exception(
                $this->translator->trans(
                    'controller.default.navigation.no_networks',
                    array(),
                    'exceptions'
                )
            );
        }

        return $networks;
    }
}
{'fraction_non_alphanumeric': 0.12403386087596614, 'fraction_numerical': 0.001840264998159735, 'mean_word_length': 1.8224299065420562, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '7426393', 'n_tokens_mistral': 759, 'n_tokens_neox': 740, 'n_words': 149}