PipelineStepService.php
- Pfad:
src/Application/PipelineStepService.php - Namespace: Application
- Zeilen: 151 | Größe: 4,717 Bytes
- Geändert: 2025-12-25 16:59:29 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 99 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 7
- constructor Domain\Repository\PipelineConfigRepositoryInterface
- constructor Domain\Repository\PipelineStepRepositoryInterface
- constructor Infrastructure\AI\ModelRegistry
- use Domain\Repository\PipelineConfigRepositoryInterface
- use Domain\Repository\PipelineStepRepositoryInterface
- use Infrastructure\AI\ModelRegistry
- use Infrastructure\Config\PipelineStepConfig
Klassen 1
-
PipelineStepServiceclass Zeile 14
Funktionen 5
-
__construct()public Zeile 16 -
toggleStep()public Zeile 28 -
updateModel()public Zeile 55 -
updateCollection()public Zeile 103 -
createDefaultSteps()public Zeile 144
Verwendet von 3
- ContentPipelineController.php constructor
- ContentPipelineController.php use
- ContentServiceProvider.php use
Versionen 8
-
v8
2025-12-25 16:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v7
2025-12-25 16:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v6
2025-12-25 16:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v5
2025-12-25 16:59 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v4
2025-12-25 16:58 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v3
2025-12-25 13:28 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-25 13:28 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-23 08:09 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Application;
// @responsibility: Service für Pipeline-Step-Operationen (Toggle, Konfiguration)
use Domain\Repository\PipelineConfigRepositoryInterface;
use Domain\Repository\PipelineStepRepositoryInterface;
use Infrastructure\AI\ModelRegistry;
use Infrastructure\Config\PipelineStepConfig;
final class PipelineStepService
{
public function __construct(
private PipelineConfigRepositoryInterface $configRepository,
private PipelineStepRepositoryInterface $stepRepository,
private ModelRegistry $modelRegistry
) {
}
/**
* Toggle a step's enabled status.
*
* @return bool True if toggled successfully
*/
public function toggleStep(int $pipelineId, int $stepId): bool
{
$pipeline = $this->configRepository->findById($pipelineId);
if ($pipeline === null) {
return false;
}
$steps = $this->stepRepository->findSteps($pipelineId);
foreach ($steps as $step) {
if ((int) $step['id'] === $stepId) {
$this->stepRepository->updateStep($stepId, [
'enabled' => $step['enabled'] ? 0 : 1,
]);
return true;
}
}
return false;
}
/**
* Update the model for a step.
*
* @return array{success: bool, error?: string, model?: string, label?: string}
*/
public function updateModel(int $pipelineId, int $stepId, string $model): array
{
$pipeline = $this->configRepository->findById($pipelineId);
if ($pipeline === null) {
return ['success' => false, 'error' => 'Pipeline nicht gefunden'];
}
$model = trim($model);
if ($model === '' || !$this->modelRegistry->isValid($model)) {
return ['success' => false, 'error' => 'Ungültiges Modell'];
}
$steps = $this->stepRepository->findSteps($pipelineId);
foreach ($steps as $step) {
if ((int) $step['id'] === $stepId) {
$config = $step['config'] ?? [];
// Determine provider from model
$provider = $this->modelRegistry->isLocal($model) ? 'ollama' : 'anthropic';
// Update config with new model
$config['model'] = $this->modelRegistry->isLocal($model)
? substr($model, 7) // Remove 'ollama:' prefix
: $model;
$config['provider'] = $provider;
$this->stepRepository->updateStep($stepId, [
'config' => $config,
]);
return [
'success' => true,
'model' => $model,
'label' => $this->modelRegistry->getLabel($model),
];
}
}
return ['success' => false, 'error' => 'Schritt nicht gefunden'];
}
/**
* Update the collection for a step.
*
* @return array{success: bool, error?: string, collection?: string, label?: string}
*/
public function updateCollection(int $pipelineId, int $stepId, string $collection): array
{
$pipeline = $this->configRepository->findById($pipelineId);
if ($pipeline === null) {
return ['success' => false, 'error' => 'Pipeline nicht gefunden'];
}
$collection = trim($collection);
$validCollections = array_keys(PipelineStepConfig::getCollections());
if ($collection === '' || !in_array($collection, $validCollections, true)) {
return ['success' => false, 'error' => 'Ungültige Collection'];
}
$steps = $this->stepRepository->findSteps($pipelineId);
foreach ($steps as $step) {
if ((int) $step['id'] === $stepId) {
$config = $step['config'] ?? [];
$config['collection'] = $collection;
$this->stepRepository->updateStep($stepId, [
'config' => $config,
]);
$collections = PipelineStepConfig::getCollections();
return [
'success' => true,
'collection' => $collection,
'label' => $collections[$collection] ?? $collection,
];
}
}
return ['success' => false, 'error' => 'Schritt nicht gefunden'];
}
/**
* Create default steps for a new pipeline.
*/
public function createDefaultSteps(int $pipelineId): void
{
foreach (PipelineStepConfig::getDefaultSteps() as $step) {
$this->stepRepository->addStep($pipelineId, $step);
}
}
}