Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Gappa committed Nov 25, 2021
1 parent f80ff9c commit d851cd3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/Contract/IBatchProvider.php

This file was deleted.

9 changes: 9 additions & 0 deletions src/Contract/IWebloaderAssetProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types = 1);

namespace WebLoader\Contract;

interface IWebloaderAssetProvider
{
public function getWebloaderAssets(): array;
}
12 changes: 6 additions & 6 deletions src/Nette/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use SplFileInfo;
use WebLoader\BatchCollection;
use WebLoader\Compiler as WebloaderCompiler;
use WebLoader\Contract\IBatchProvider;
use WebLoader\Contract\IWebloaderAssetProvider;
use WebLoader\Exception\CompilationException;
use WebLoader\FileCollection;
use WebLoader\Exception\FileNotFoundException;
Expand Down Expand Up @@ -334,8 +334,8 @@ protected function fileExists(string $file): bool
private function extractBatchesFromExtensions(): void
{
// Extension batches
/** @var array<IBatchProvider> $batchProviders */
$batchProviders = $this->compiler->getExtensions(IBatchProvider::class);
/** @var array<IWebloaderAssetProvider> $batchProviders */
$batchProviders = $this->compiler->getExtensions(IWebloaderAssetProvider::class);

if (empty($batchProviders)) {
return;
Expand All @@ -344,10 +344,10 @@ private function extractBatchesFromExtensions(): void
$schemaProcessor = new Processor;

foreach($batchProviders as $batchProvider) {
$batchCollections = $batchProvider->getBatches();
$schemaProcessor->process($this->getConfigSchema(), $batchCollections);
$assets = $batchProvider->getWebloaderAssets();
$schemaProcessor->process($this->getConfigSchema(), $assets);

foreach ($batchCollections as $type => $batches) {
foreach ($assets as $type => $batches) {
foreach ($batches as $name => $batch) {
$this->batchCollection->addBatch($type, $name, $batch);
}
Expand Down

0 comments on commit d851cd3

Please sign in to comment.