1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\DependencyInjection\Exception;
13
14/**
15 * This exception is thrown when a circular reference is detected.
16 *
17 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
18 */
19class ServiceCircularReferenceException extends RuntimeException
20{
21    private $serviceId;
22    private $path;
23
24    public function __construct($serviceId, array $path, \Exception $previous = null)
25    {
26        parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous);
27
28        $this->serviceId = $serviceId;
29        $this->path = $path;
30    }
31
32    public function getServiceId()
33    {
34        return $this->serviceId;
35    }
36
37    public function getPath()
38    {
39        return $this->path;
40    }
41}
42