2018-01-12 04:49:46 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-20 03:47:06 +00:00
|
|
|
namespace Pterodactyl\Transformers\Api\Application;
|
2018-01-12 04:49:46 +00:00
|
|
|
|
|
|
|
use Illuminate\Container\Container;
|
2021-08-07 20:06:45 +00:00
|
|
|
use Pterodactyl\Transformers\Api\Transformer;
|
2018-02-25 21:30:56 +00:00
|
|
|
use Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException;
|
2018-01-12 04:49:46 +00:00
|
|
|
|
2021-08-07 20:06:45 +00:00
|
|
|
abstract class BaseTransformer extends Transformer
|
2018-01-12 04:49:46 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new instance of the transformer and pass along the currently
|
|
|
|
* set API key.
|
|
|
|
*
|
2018-01-20 03:47:06 +00:00
|
|
|
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
2018-02-25 21:30:56 +00:00
|
|
|
*
|
2021-01-01 22:55:30 +00:00
|
|
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
2018-02-25 21:30:56 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
2018-01-12 04:49:46 +00:00
|
|
|
*/
|
2018-02-25 21:30:56 +00:00
|
|
|
protected function makeTransformer(string $abstract, array $parameters = [])
|
2018-01-12 04:49:46 +00:00
|
|
|
{
|
2018-01-20 03:47:06 +00:00
|
|
|
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
|
2018-01-12 04:49:46 +00:00
|
|
|
$transformer = Container::getInstance()->makeWith($abstract, $parameters);
|
|
|
|
|
2021-01-24 01:17:35 +00:00
|
|
|
if (!$transformer instanceof self) {
|
2018-02-25 21:30:56 +00:00
|
|
|
throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__);
|
|
|
|
}
|
|
|
|
|
2018-01-12 04:49:46 +00:00
|
|
|
return $transformer;
|
|
|
|
}
|
|
|
|
}
|