orm gr protected

This commit is contained in:
Yuri Kuznetsov
2021-07-27 16:36:48 +03:00
parent 64e7c1081b
commit db46faef29
9 changed files with 57 additions and 61 deletions
+4 -4
View File
@@ -40,13 +40,13 @@ use RuntimeException;
class BaseLocker implements Locker
{
protected $pdo;
private $pdo;
protected $queryComposer;
private $queryComposer;
protected $transactionManager;
private $transactionManager;
protected $isLocked = false;
private $isLocked = false;
public function __construct(PDO $pdo, QueryComposer $queryComposer, TransactionManager $transactionManager)
{
+4 -4
View File
@@ -43,13 +43,13 @@ use RuntimeException;
*/
class MysqlLocker implements Locker
{
protected $pdo;
private $pdo;
protected $queryComposer;
private $queryComposer;
protected $transactionManager;
private $transactionManager;
protected $isLocked = false;
private $isLocked = false;
public function __construct(PDO $pdo, QueryComposer $queryComposer, TransactionManager $transactionManager)
{
+2 -2
View File
@@ -41,9 +41,9 @@ use PDOStatement;
*/
class QueryExecutor
{
protected $sqlExecutor;
private $sqlExecutor;
protected $queryComposer;
private $queryComposer;
public function __construct(SqlExecutor $sqlExecutor, QueryComposer $queryComposer)
{
+21 -21
View File
@@ -48,23 +48,23 @@ use RuntimeException;
*/
class RDBRelation
{
protected $entityManager;
private $entityManager;
protected $hookMediator;
private $hookMediator;
protected $entity;
private $entity;
protected $entityType;
private $entityType;
protected $foreignEntityType = null;
private $foreignEntityType = null;
protected $relationName;
private $relationName;
protected $relationType = null;
private $relationType = null;
protected $builder = null;
private $builder = null;
protected $noBuilder = false;
private $noBuilder = false;
public function __construct(
EntityManager $entityManager,
@@ -100,7 +100,7 @@ class RDBRelation
/**
* Create a select builder.
*/
protected function createSelectBuilder(?Select $query = null): Builder
private function createSelectBuilder(?Select $query = null): Builder
{
if ($this->noBuilder) {
throw new RuntimeException("Can't use query builder for the '{$this->relationType}' relation type.");
@@ -125,12 +125,12 @@ class RDBRelation
return $this->createSelectBuilder($query);
}
protected function isBelongsToParentType(): bool
private function isBelongsToParentType(): bool
{
return $this->relationType === Entity::BELONGS_TO_PARENT;
}
protected function getMapper(): RDBMapper
private function getMapper(): RDBMapper
{
return $this->entityManager->getMapper();
}
@@ -340,7 +340,7 @@ class RDBRelation
return $this->createSelectBuilder()->columnsWhere($clause);
}
protected function processCheckForeignEntity(Entity $entity): void
private function processCheckForeignEntity(Entity $entity): void
{
if ($this->foreignEntityType && $this->foreignEntityType !== $entity->getEntityType()) {
throw new RuntimeException("Entity type doesn't match an entity type of the relation.");
@@ -378,7 +378,7 @@ class RDBRelation
->findOne();
}
protected function isRelatedBelongsToParent(Entity $entity): bool
private function isRelatedBelongsToParent(Entity $entity): bool
{
$fromEntity = $this->entity;
@@ -399,7 +399,7 @@ class RDBRelation
$fromEntity->get($typeAttribute) === $entity->getEntityType();
}
protected function isRelatedBelongsTo(Entity $entity): bool
private function isRelatedBelongsTo(Entity $entity): bool
{
$fromEntity = $this->entity;
@@ -554,32 +554,32 @@ class RDBRelation
return $this->getMapper()->getRelationColumn($this->entity, $this->relationName, $entity->getId(), $column);
}
protected function beforeRelate(Entity $entity, ?array $columnData, array $options): void
private function beforeRelate(Entity $entity, ?array $columnData, array $options): void
{
$this->hookMediator->beforeRelate($this->entity, $this->relationName, $entity, $columnData, $options);
}
protected function afterRelate(Entity $entity, ?array $columnData, array $options): void
private function afterRelate(Entity $entity, ?array $columnData, array $options): void
{
$this->hookMediator->afterRelate($this->entity, $this->relationName, $entity, $columnData, $options);
}
protected function beforeUnrelate(Entity $entity, array $options): void
private function beforeUnrelate(Entity $entity, array $options): void
{
$this->hookMediator->beforeUnrelate($this->entity, $this->relationName, $entity, $options);
}
protected function afterUnrelate(Entity $entity, array $options): void
private function afterUnrelate(Entity $entity, array $options): void
{
$this->hookMediator->afterUnrelate($this->entity, $this->relationName, $entity, $options);
}
protected function beforeMassRelate(Select $query, array $options): void
private function beforeMassRelate(Select $query, array $options): void
{
$this->hookMediator->beforeMassRelate($this->entity, $this->relationName, $query, $options);
}
protected function afterMassRelate(Select $query, array $options): void
private function afterMassRelate(Select $query, array $options): void
{
$this->hookMediator->afterMassRelate($this->entity, $this->relationName, $query, $options);
}
@@ -50,30 +50,26 @@ use InvalidArgumentException;
*/
class RDBRelationSelectBuilder
{
protected $entityManager;
private $entityManager;
protected $entity;
private $entity;
protected $entityType;
private $entityType;
protected $foreignEntityType;
private $foreignEntityType;
protected $relationName;
private $relationName;
protected $relationType = null;
private $relationType = null;
/**
* @var SelectBuilder
*/
protected $builder = null;
protected $additionalSelect = [];
protected $selectIsAdded = false;
private $builder = null;
private $middleTableAlias = null;
protected $returnSthCollection = false;
private $returnSthCollection = false;
public function __construct(
EntityManager $entityManager,
@@ -49,15 +49,15 @@ use RuntimeException;
*/
class RDBSelectBuilder
{
protected $entityManager;
private $entityManager;
protected $builder;
private $builder;
protected $repository = null;
private $repository = null;
protected $entityType = null;
private $entityType = null;
protected $returnSthCollection = false;
private $returnSthCollection = false;
public function __construct(EntityManager $entityManager, string $entityType, ?Select $query = null)
{
@@ -40,9 +40,9 @@ use RuntimeException;
*/
class RDBTransactionManager
{
protected $transactionManager;
private $transactionManager;
protected $level = 0;
private $level = 0;
public function __construct(TransactionManager $transactionManager)
{
+4 -4
View File
@@ -41,9 +41,9 @@ use RuntimeException;
*/
class SqlExecutor
{
protected $pdo;
private $pdo;
const MAX_ATTEMPT_COUNT = 4;
private const MAX_ATTEMPT_COUNT = 4;
public function __construct(PDO $pdo)
{
@@ -62,7 +62,7 @@ class SqlExecutor
return $this->executeSqlWithDeadlockHandling($sql);
}
protected function executeSqlWithDeadlockHandling(string $sql, ?int $counter = null): PDOStatement
private function executeSqlWithDeadlockHandling(string $sql, ?int $counter = null): PDOStatement
{
$counter = $counter ?? self::MAX_ATTEMPT_COUNT;
@@ -86,7 +86,7 @@ class SqlExecutor
return $sth;
}
protected function isExceptionIsDeadlock(Exception $e): bool
private function isExceptionIsDeadlock(Exception $e): bool
{
if (!$e instanceof PDOException) {
return false;
+7 -7
View File
@@ -40,11 +40,11 @@ use Closure;
class TransactionManager
{
protected $level = 0;
private $level = 0;
protected $pdo;
private $pdo;
protected $queryComposer;
private $queryComposer;
public function __construct(PDO $pdo, QueryComposer $queryComposer)
{
@@ -149,26 +149,26 @@ class TransactionManager
$this->pdo->rollBack();
}
protected function getCurrentSavepoint(): string
private function getCurrentSavepoint(): string
{
return 'POINT_' . (string) $this->level;
}
protected function createSavepoint(): void
private function createSavepoint(): void
{
$sql = $this->queryComposer->composeCreateSavepoint($this->getCurrentSavepoint());
$this->pdo->exec($sql);
}
protected function releaseSavepoint(): void
private function releaseSavepoint(): void
{
$sql = $this->queryComposer->composeReleaseSavepoint($this->getCurrentSavepoint());
$this->pdo->exec($sql);
}
protected function rollbackToSavepoint(): void
private function rollbackToSavepoint(): void
{
$sql = $this->queryComposer->composeRollbackToSavepoint($this->getCurrentSavepoint());