Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old datastore interface (v7) #134

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ RQL - простой язык построения запросов для аб
```
- Строковое представление: `in`. Пример:
```php
$query = 'in(name,John,Jackson,Liam)';
$query = 'in(name,(John,Jackson,Liam))';
```
* `out`. Оператор который позволяет определить, НЕ совпадает ли значение поля со значением в списке (обратное к `in`).
- Объект: `Xiag\Rql\Parser\Node\Query\ArrayOperator\OutNode`. Пример:
Expand All @@ -476,7 +476,7 @@ RQL - простой язык построения запросов для аб
```
- Строковое представление: `out`. Пример:
```php
$query = 'out(name,Grayson,Lucas)';
$query = 'out(name,(Grayson,Lucas))';

2. Логические операторы.
* `and`. Оператор, который отображает только те записи, когда все условие является правдой (`true`).
Expand Down Expand Up @@ -1139,4 +1139,4 @@ $result = $fileObject->getRowById('1'); // array

До версии "6.6.1" есть баг в классе CsvBinaryStrategy (которы отвечает за бинарный поиск), из-за которой некорректно
работал поиск (если запускать его больше одного раза) и добавление новых строк. Причина в том, что после поиска не
обнулялось поле $uniqueIterations и влияло на результаты следующих поисков.
обнулялось поле $uniqueIterations и влияло на результаты следующих поисков.
4 changes: 2 additions & 2 deletions src/DataStore/src/AbstractFactoryAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace rollun\datastore;

use rollun\datastore\DataStore\Interfaces\DataStoresInterface;
use rollun\datastore\DataStore\Interfaces\DataStoreInterface;
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Interop\Container\ContainerInterface;
Expand Down Expand Up @@ -58,7 +58,7 @@ abstract public function canCreate(ContainerInterface $container, $requestedName
* @param ContainerInterface $container
* @param string $requestedName
* @param array $options
* @return DataStoresInterface
* @return DataStoreInterface
*/
abstract public function __invoke(ContainerInterface $container, $requestedName, array $options = null);

Expand Down
6 changes: 3 additions & 3 deletions src/DataStore/src/Cleaner/CleanableListAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

use Exception;
use rollun\utils\Cleaner\CleanableList\CleanableListInterface;
use rollun\datastore\DataStore\Interfaces\DataStoresInterface;
use rollun\datastore\DataStore\Interfaces\DataStoreInterface;
use rollun\datastore\DataStoreCleanerException;

class CleanableListAdapter implements \IteratorAggregate, CleanableListInterface
{
/**
* @var DataStoresInterface
* @var DataStoreInterface
*/
protected $datastore;

public function __construct(DataStoresInterface $datastore)
public function __construct(DataStoreInterface $datastore)
{
$this->datastore = $datastore;
}
Expand Down
4 changes: 2 additions & 2 deletions src/DataStore/src/Cleaner/Cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

use rollun\utils\Cleaner\CleaningValidator\CleaningValidatorInterface;
use rollun\utils\Cleaner\Cleaner as BaseCleaner;
use rollun\datastore\DataStore\Interfaces\DataStoresInterface;
use rollun\datastore\DataStore\Interfaces\DataStoreInterface;

/**
* Class Cleaner
* @package rollun\datastore\Cleaner
*/
class Cleaner extends BaseCleaner
{
public function __construct(DataStoresInterface $datastore, CleaningValidatorInterface $cleaningValidator)
public function __construct(DataStoreInterface $datastore, CleaningValidatorInterface $cleaningValidator)
{
$cleanableList = new CleanableListAdapter($datastore);
parent::__construct($cleanableList, $cleaningValidator);
Expand Down
2 changes: 0 additions & 2 deletions src/DataStore/src/DataStore/Aspect/AbstractMapperAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use rollun\datastore\DataStore\DataStoreException;
use rollun\datastore\DataStore\Traits\NoSupportCreateTrait;
use rollun\datastore\DataStore\Traits\NoSupportDeleteAllTrait;
use rollun\datastore\DataStore\Traits\NoSupportDeleteTrait;
use rollun\datastore\DataStore\Traits\NoSupportUpdateTrait;
use Xiag\Rql\Parser\Node\AbstractQueryNode;
Expand All @@ -22,7 +21,6 @@ abstract class AbstractMapperAspect extends AspectAbstract
{
use NoSupportUpdateTrait;
use NoSupportCreateTrait;
use NoSupportDeleteAllTrait;
use NoSupportDeleteTrait;

/**
Expand Down
74 changes: 17 additions & 57 deletions src/DataStore/src/DataStore/Aspect/AspectAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
namespace rollun\datastore\DataStore\Aspect;

use rollun\datastore\DataStore\Interfaces\DataStoreInterface;
use rollun\datastore\DataStore\Interfaces\DataStoresInterface;
use Xiag\Rql\Parser\Query;

/**
* Class AspectAbstract
*
* This is wrapper for any type of datastore which allows to do 'pre' and 'post' actions
* for each method of the DataStoresInterface.
* for each method of the DataStoreInterface.
*
* The class is NOT abstract. It is so named because in this view it does nothing and have no difference at work
* with usual datastore any type.
*
* @see AspectAbstractFactory
* @package rollun\datastore\DataStore\Aspect
*/
class AspectAbstract implements DataStoresInterface, DataStoreInterface
class AspectAbstract implements DataStoreInterface
{
/** @var DataStoresInterface $dataStore */
/** @var DataStoreInterface $dataStore */
protected $dataStore;

/**
* AspectDataStoreAbstract constructor.
*
* @param DataStoresInterface $dataStore
* @param DataStoreInterface $dataStore
*/
public function __construct(DataStoresInterface $dataStore)
public function __construct(DataStoreInterface $dataStore)
{
$this->dataStore = $dataStore;
}
Expand Down Expand Up @@ -77,10 +76,9 @@ protected function postGetIterator(\Traversable $iterator)
* By default does nothing
*
* @param $itemData
* @param bool|false $rewriteIfExist
* @return array
*/
protected function preCreate($itemData, $rewriteIfExist = false)
protected function preCreate($itemData)
{
return $itemData;
}
Expand All @@ -90,12 +88,12 @@ protected function preCreate($itemData, $rewriteIfExist = false)
*
* {@inheritdoc}
*/
public function create($itemData, $rewriteIfExist = false)
public function create($itemData)
{
$newData = $this->preCreate($itemData, $rewriteIfExist);
$result = $this->dataStore->create($newData, $rewriteIfExist);
$newData = $this->preCreate($itemData);
$result = $this->dataStore->create($newData);

return $this->postCreate($result, $newData, $rewriteIfExist);
return $this->postCreate($result, $newData);
}

/**
Expand All @@ -105,10 +103,9 @@ public function create($itemData, $rewriteIfExist = false)
*
* @param $result
* @param $itemData
* @param $rewriteIfExist
* @return mixed
*/
protected function postCreate($result, $itemData, $rewriteIfExist)
protected function postCreate($result, $itemData)
{
return $result;
}
Expand All @@ -119,10 +116,9 @@ protected function postCreate($result, $itemData, $rewriteIfExist)
* By default does nothing
*
* @param $itemData
* @param bool|false $createIfAbsent
* @return array
*/
protected function preUpdate($itemData, $createIfAbsent = false)
protected function preUpdate($itemData)
{
return $itemData;
}
Expand All @@ -132,12 +128,12 @@ protected function preUpdate($itemData, $createIfAbsent = false)
*
* {@inheritdoc}
*/
public function update($itemData, $createIfAbsent = false)
public function update($itemData)
{
$newData = $this->preUpdate($itemData, $createIfAbsent);
$result = $this->dataStore->update($newData, $createIfAbsent);
$newData = $this->preUpdate($itemData);
$result = $this->dataStore->update($newData);

return $this->postUpdate($result, $newData, $createIfAbsent);
return $this->postUpdate($result, $newData);
}

/**
Expand All @@ -147,10 +143,9 @@ public function update($itemData, $createIfAbsent = false)
*
* @param mixed $result
* @param $itemData
* @param $createIfAbsent
* @return mixed
*/
protected function postUpdate($result, $itemData, $createIfAbsent)
protected function postUpdate($result, $itemData)
{
return $result;
}
Expand Down Expand Up @@ -193,41 +188,6 @@ protected function postDelete($result, $id)
return $result;
}

/**
* The pre-aspect for "deleteAll".
*
* By default does nothing
*/
protected function preDeleteAll()
{
}

/**
* {@inheritdoc}
*
* {@inheritdoc}
*/
public function deleteAll()
{
$this->preDeleteAll();
$result = $this->dataStore->deleteAll();

return $this->postDeleteAll($result);
}

/**
* The post-aspect for "deleteAll"
*
* By default does nothing
*
* @param mixed $result
* @return mixed
*/
protected function postDeleteAll($result)
{
return $result;
}

/**
* The pre-aspect for "getIdentifier".
*
Expand Down
14 changes: 7 additions & 7 deletions src/DataStore/src/DataStore/Aspect/AspectTyped.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use rollun\datastore\DataStore\BaseDto;
use rollun\datastore\DataStore\Formatter\FormatterInterface;
use rollun\datastore\DataStore\Formatter\FormatterPluginManager;
use rollun\datastore\DataStore\Interfaces\DataStoresInterface;
use rollun\datastore\DataStore\Interfaces\DataStoreInterface;
use rollun\datastore\DataStore\Interfaces\SchemableInterface;
use rollun\datastore\DataStore\Type\TypePluginManager;
use RuntimeException;
Expand Down Expand Up @@ -41,14 +41,14 @@ class AspectTyped extends AspectAbstract implements SchemableInterface

/**
* AspectTyped constructor.
* @param DataStoresInterface $dataStore
* @param DataStoreInterface $dataStore
* @param array $scheme
* @param string $dtoClassName
* @param TypePluginManager|null $typePluginManager
* @param FormatterPluginManager|null $formatterPluginManager
*/
public function __construct(
DataStoresInterface $dataStore,
DataStoreInterface $dataStore,
array $scheme,
string $dtoClassName,
TypePluginManager $typePluginManager = null,
Expand Down Expand Up @@ -89,7 +89,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
protected function preUpdate($itemData, $createIfAbsent = false)
protected function preUpdate($itemData)
{
if ($itemData instanceof BaseDto) {
$itemData = $this->dtoToArray($itemData);
Expand All @@ -101,7 +101,7 @@ protected function preUpdate($itemData, $createIfAbsent = false)
/**
* {@inheritdoc}
*/
protected function postUpdate($result, $itemData, $rewriteIfExist)
protected function postUpdate($result, $itemData)
{
if (is_array($result)) {
return $this->arrayToDto($result);
Expand All @@ -113,7 +113,7 @@ protected function postUpdate($result, $itemData, $rewriteIfExist)
/**
* {@inheritdoc}
*/
protected function preCreate($itemData, $rewriteIfExist = false)
protected function preCreate($itemData)
{
if ($itemData instanceof BaseDto) {
$itemData = $this->dtoToArray($itemData);
Expand All @@ -125,7 +125,7 @@ protected function preCreate($itemData, $rewriteIfExist = false)
/**
* {@inheritdoc}
*/
protected function postCreate($result, $itemData, $rewriteIfExist)
protected function postCreate($result, $itemData)
{
if (is_array($result)) {
return $this->arrayToDto($result);
Expand Down
Loading