Skip to content

Commit

Permalink
Copy extension services and routes into Bolt
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Valchev committed Jul 16, 2020
1 parent fbbcac8 commit c71185c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Extension/ExtensionCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function process(ContainerBuilder $container): void

// Rebuild our own `services_bolt.yml` file.
$this->buildServices($packages);
$this->copyExtensionServices($packages);
$this->copyExtensionRoutesAndServices($packages);
}

public function buildServices(array $packages): void
Expand Down Expand Up @@ -62,21 +62,25 @@ public function buildServices(array $packages): void
file_put_contents($filename, $yaml);
}

public function copyExtensionServices(array $packages): void
public function copyExtensionRoutesAndServices(array $packages): void
{
foreach ($packages as $package) {
$reflection = new \ReflectionClass($package);

$extensionRoutesPath = $this->getRelativePath($package) . '/../config/routes.yaml';
dump($package);
if (file_exists($extensionRoutesPath)) {
$filename = $this->projectDir . '/config/routes/extension_' . $reflection->get();
dump("Dumping " . $extensionRoutesPath . ' into ' . $filename);
// file_put_contents($filename, file_get_contents($extensionRoutesPath));
$path = dirname(dirname($reflection->getFilename()));
$filename = $this->projectDir . '/config/routes/extension_' . Str::splitLast($path, '/') . '.yaml';
file_put_contents($filename, file_get_contents($extensionRoutesPath));
}
}

die;
$extensionServicesPath = $this->getRelativePath($package) . '/../config.services.yaml';
if (file_exists($extensionServicesPath)) {
$path = dirname(dirname($reflection->getFilename()));
$filename = $this->projectDir . '/config/packages/services_extension_' . Str::splitLast($path, '/') . '.yaml';
file_put_contents($filename, file_get_contents($extensionRoutesPath));
}
}
}

private function createService(string $package): array
Expand Down

0 comments on commit c71185c

Please sign in to comment.