EntityInUseException.php (802B)
1 <?php 2 /** 3 * Created by PhpStorm. 4 * User: felicitus 5 * Date: 10/25/17 6 * Time: 11:45 PM. 7 */ 8 9 namespace PartKeepr\DoctrineReflectionBundle\Exception; 10 11 use PartKeepr\CoreBundle\Exceptions\TranslatableException; 12 13 class EntityInUseException extends TranslatableException 14 { 15 public $usedBy = []; 16 17 public $entityName; 18 19 public function __construct($entityName, array $usedBy, $code = 0, \Throwable $previous = null) 20 { 21 $this->usedBy = $usedBy; 22 $this->entityName = $entityName; 23 $this->{'hydra:title'} = $this->getMessageKey(); 24 $this->{'hydra:description'} = implode("<br/>", $usedBy); 25 26 parent::__construct($code, $previous); 27 } 28 29 public function getMessageKey() 30 { 31 return sprintf('%s is in use by:', (string) $this->entityName); 32 } 33 }