Skip to content

Commit

Permalink
♿ use Laravel to make new instances of transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tini committed Nov 7, 2024
1 parent 558c560 commit 84a677e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Transformers/TransformerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public function createFromModel($model): TransformerInterface
return $this->transformers[$modelClass];
}

foreach ($this->transformerMap as $class => $transformer) {
foreach ($this->transformerMap as $class => $transformerClass) {
if (is_a($modelClass, $class, true)) {
return $this->transformers[$modelClass] = $this->injectDependencies(new $transformer($this));
$transformer = app()->make($transformerClass);
return $this->transformers[$modelClass] = $this->injectDependencies($transformer);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/Transformers/TransformerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

interface TransformerInterface
{
public function __construct(TransformerFactory $transformerFactory);

public function transform($model): array;

public function transformIdentifier($model, bool $includeMeta = false): array;
Expand Down

0 comments on commit 84a677e

Please sign in to comment.