Further modules included.
[yaffs-website] / web / modules / contrib / libraries / src / ExternalLibrary / Exception / InvalidLibraryDependencyException.php
1 <?php
2
3 namespace Drupal\libraries\ExternalLibrary\Exception;
4
5 use Drupal\libraries\ExternalLibrary\Utility\DependencyAccessorTrait;
6 use Drupal\libraries\ExternalLibrary\LibraryInterface;
7 use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorTrait;
8 use Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorInterface;
9
10 /**
11  * Provides an exception for an invalid library exception.
12  */
13 class InvalidLibraryDependencyException extends \UnexpectedValueException implements LibraryAccessorInterface {
14
15   use LibraryAccessorTrait;
16   use DependencyAccessorTrait;
17
18   /**
19    * Constructs a library exception.
20    *
21    * @param \Drupal\libraries\ExternalLibrary\LibraryInterface $library
22    *   The library with the invalid dependency.
23    * @param \Drupal\libraries\ExternalLibrary\LibraryInterface $dependency
24    *   The dependency.
25    * @param string $message
26    *   (optional) The exception message.
27    * @param int $code
28    *   (optional) The error code.
29    * @param \Exception $previous
30    *   (optional) The previous exception.
31    */
32   public function __construct(
33     LibraryInterface $library,
34     LibraryInterface $dependency,
35     $message = '',
36     $code = 0,
37     \Exception $previous = NULL
38   ) {
39     $this->library = $library;
40     $this->dependency = $dependency;
41     $message = $message ?: "The library '{$this->library->getId()}' cannot depend on the library '{$this->dependency->getId()}'.";
42     parent::__construct($message, $code, $previous);
43   }
44
45 }