Skip to content

Commit

Permalink
feat(ddev): add missing ddev method implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Jul 16, 2022
1 parent fcb8162 commit 11bf097
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/Method/DdevMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Phabalicious\Method;

use Phabalicious\Configuration\ConfigurationService;
use Phabalicious\Configuration\Storage\Node;
use Phabalicious\Utilities\Utilities;
use Phabalicious\Validation\ValidationErrorBagInterface;
use Phabalicious\Validation\ValidationService;

class DdevMethod extends BaseMethod implements MethodInterface
{

public function getName(): string
{
return 'ddev';
}

public function supports(string $method_name): bool
{
return $method_name === $this->getName();
}

public function getGlobalSettings(ConfigurationService $configuration): Node
{
$node = new Node([], $this->getName() . ' global settings');
$config_file = $configuration->getFabfilePath() . '/.ddev/config.yaml';
if (file_exists($config_file)) {
$data = Node::parseYamlFile($config_file);
$node->set('ddev', $data);
}

return $node;
}

public function validateGlobalSettings(Node $settings, ValidationErrorBagInterface $errors)
{
if ($settings->has('ddev')) {
$ddev = $settings['ddev'];
$service = new ValidationService($ddev, $errors, 'ddev settings');
$service->hasKey('name', 'the ddev project-name is missing');
} else {
$errors->addError('ddev', 'No ddev config found, check `.ddev/config.yaml`');
}
}

public function getMethodDependencies(MethodFactory $factory, \ArrayAccess $data): array
{
return [
DockerMethod::METHOD_NAME
];
}
}

0 comments on commit 11bf097

Please sign in to comment.