Skip to content

Commit

Permalink
Merge pull request #1 from imatic/parklane
Browse files Browse the repository at this point in the history
Symfony4 support
  • Loading branch information
stepankoci committed Nov 7, 2018
2 parents ba28d7f + d5a3fd5 commit 35afd4e
Show file tree
Hide file tree
Showing 236 changed files with 1,937 additions and 2,314 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ return PhpCsFixer\Config::create()
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'ereg_to_preg' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
Expand Down
20 changes: 15 additions & 5 deletions Command/QueryObjectQueryCommand.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Command;

use Doctrine\Common\Util\Debug;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Imatic\Bundle\DataBundle\Data\Query\QueryExecutorInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class QueryObjectQueryCommand extends ContainerAwareCommand
class QueryObjectQueryCommand extends Command
{
const OPTION_ARGS = 'args';

/** @var QueryExecutorInterface */
private $queryExecutor;

public function __construct(QueryExecutorInterface $queryExecutor)
{
$this->queryExecutor = $queryExecutor;

parent::__construct();
}

protected function configure()
{
$this
Expand Down Expand Up @@ -40,8 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$queryObject = $classRef->newInstanceArgs($args);

$queryExecutor = $this->getContainer()->get('imatic_data.query_executor');
$result = $queryExecutor->execute($queryObject);
$result = $this->queryExecutor->execute($queryObject);

$output->writeln(Debug::dump($result, 2, false, false));
}
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/Command.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

use Imatic\Bundle\DataBundle\Exception\ParameterNotFoundException;
Expand Down
3 changes: 2 additions & 1 deletion Data/Command/CommandExecutor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

class CommandExecutor implements CommandExecutorInterface
Expand Down Expand Up @@ -33,6 +33,7 @@ public function __construct(HandlerRepositoryInterface $handlerRepository, $debu
public function execute(CommandInterface $command)
{
$commandHandler = $this->handlerRepository->getHandler($command);

if ($commandHandler instanceof CommandExecutorAwareInterface) {
$commandHandler->setCommandExecutor($this);
}
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandExecutorAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface CommandExecutorAwareInterface
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandExecutorAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

trait CommandExecutorAwareTrait
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandExecutorInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface CommandExecutorInterface
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

use Imatic\Bundle\DataBundle\Exception\ParameterNotFoundException;
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandResult.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

class CommandResult implements CommandResultInterface
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/CommandResultInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface CommandResultInterface
Expand Down
122 changes: 0 additions & 122 deletions Data/Command/ContainerHandlerRepository.php

This file was deleted.

2 changes: 1 addition & 1 deletion Data/Command/HandlerInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface HandlerInterface
Expand Down
70 changes: 32 additions & 38 deletions Data/Command/HandlerRepository.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

use Imatic\Bundle\DataBundle\Exception\HandlerNotFoundException;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;

class HandlerRepository implements HandlerRepositoryInterface
class HandlerRepository implements HandlerRepositoryInterface, ServiceSubscriberInterface
{
/**
* @var HandlerInterface[]
* @var ContainerInterface
*/
private $handlers;
private $locator;

/**
* @var string[]
* [
* handlerName => bundleName,
* ...
* ]
*/
private $bundles;

public function __construct()
/**
* @param ContainerInterface $locator
*/
public function __construct(ContainerInterface $locator)
{
$this->handlers = [];
$this->locator = $locator;
$this->bundles = [];
}

public function addHandler($name, HandlerInterface $handler, $bundleName)
{
if ($this->hasHandler($name)) {
throw new \LogicException(\sprintf('Cannot register 2nd handler with name "%s".', $name));
}

$this->handlers[$name] = $handler;
$this->bundles[$name] = $bundleName;
}

public function getHandlers()
public function getHandler(CommandInterface $command): HandlerInterface
{
return $this->handlers;
}
$handlerName = $command->getHandlerName();

public function getHandler(CommandInterface $command)
{
$name = $command->getHandlerName();
if ($this->hasHandler($name)) {
return $this->handlers[$name];
if ($this->locator->has($handlerName)) {
return $this->locator->get($handlerName);
}
throw new HandlerNotFoundException($name);

throw new HandlerNotFoundException($handlerName);
}

/**
* @param CommandInterface|string $command
*
* @return string
*/
public function getBundleName($command)
public function getBundleName($command): ?string
{
if ($command instanceof CommandInterface) {
$command = $command->getHandlerName();
Expand All @@ -56,13 +50,13 @@ public function getBundleName($command)
return $this->bundles[$command];
}

/**
* @param string $name
*
* @return bool
*/
public function hasHandler($name)
public function addBundleName(string $handlerId, ?string $bundleName)
{
$this->bundles[$handlerId] = $bundleName;
}

public static function getSubscribedServices()
{
return \array_key_exists($name, $this->handlers);
return [];
}
}
27 changes: 7 additions & 20 deletions Data/Command/HandlerRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface HandlerRepositoryInterface
{
/**
* @param string $handlerName
* @param HandlerInterface $handler
* @param string $bundleName
*/
public function addHandler($handlerName, HandlerInterface $handler, $bundleName);

/**
* @return HandlerInterface[]
*/
public function getHandlers();

/**
* @param CommandInterface $command
*
* @return HandlerInterface
*/
public function getHandler(CommandInterface $command);
public function getHandler(CommandInterface $command): HandlerInterface;

/**
* @param CommandInterface|string $command
*
* @return string
* @return string|null
*/
public function getBundleName($command);
public function getBundleName($command): ?string;

/**
* @param string $handlerName
*
* @return bool
* @param string $handlerId
* @param string|null $bundleName
*/
public function hasHandler($handlerName);
public function addBundleName(string $handlerId, ?string $bundleName);
}
2 changes: 1 addition & 1 deletion Data/Command/Message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

class Message implements MessageInterface
Expand Down
2 changes: 1 addition & 1 deletion Data/Command/MessageInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Command;

interface MessageInterface
Expand Down
2 changes: 1 addition & 1 deletion Data/Driver/DoctrineCommon/DisplayCriteriaQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace Imatic\Bundle\DataBundle\Data\Driver\DoctrineCommon;

use Doctrine\DBAL\Query\QueryBuilder as DBALQueryBuilder;
Expand Down

0 comments on commit 35afd4e

Please sign in to comment.