-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
353 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
namespace Colibri\Core; | ||
|
||
use Colibri\Core\Entity\EntityInterface; | ||
use Colibri\ServiceContainer\ServiceLocatorInterface; | ||
|
||
/** | ||
* Class EntityManager | ||
* @package Colibri\Core | ||
*/ | ||
class EntityManager | ||
{ | ||
|
||
/** | ||
* @var ServiceLocatorInterface | ||
*/ | ||
protected $serviceLocator; | ||
|
||
protected $toPersistEntities; | ||
|
||
/** | ||
* EntityManager constructor. | ||
* @param ServiceLocatorInterface $serviceLocator | ||
*/ | ||
public function __construct(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$this->serviceLocator = $serviceLocator; | ||
} | ||
|
||
/** | ||
* @param EntityInterface $entity | ||
* @param bool $forcePersist | ||
* @return $this | ||
*/ | ||
public function persist(EntityInterface $entity, $forcePersist = false) | ||
{ | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param EntityInterface $entity | ||
* @param bool $forceRemove | ||
* @return $this | ||
*/ | ||
public function remove(EntityInterface $entity, $forceRemove = false) | ||
{ | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param $class | ||
* @return Metadata | ||
*/ | ||
public function getMetadataFor($class) | ||
{ | ||
return $this->getMetadataManager()->getMetadataFor($class); | ||
} | ||
|
||
/** | ||
* @param $class | ||
* @return Entity\RepositoryInterface | ||
*/ | ||
public function getRepositoryFor($class) | ||
{ | ||
return $this->getRepositoryManager()->getRepositoryFor($class); | ||
} | ||
|
||
/** | ||
* @return MetadataManager | ||
*/ | ||
public function getMetadataManager() | ||
{ | ||
return $this->getServiceLocator()->getMetadataManager(); | ||
} | ||
|
||
/** | ||
* @return RepositoryManager | ||
*/ | ||
public function getRepositoryManager() | ||
{ | ||
return $this->getServiceLocator()->getRepositoryManager(); | ||
} | ||
|
||
/** | ||
* @return ClassManager | ||
*/ | ||
public function getClassManager() | ||
{ | ||
return $this->getServiceLocator()->getClassManager(); | ||
} | ||
|
||
/** | ||
* @return ServiceLocatorInterface | ||
*/ | ||
public function getServiceLocator(): ServiceLocatorInterface | ||
{ | ||
return $this->serviceLocator; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Colibri/Core/Repository/BasicRepositoryQueryFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Colibri\Core\Repository; | ||
|
||
/** | ||
* Class BasicRepositoryQueryFactory | ||
* @package Colibri\Core\Repository | ||
*/ | ||
class BasicRepositoryQueryFactory extends RepositoryQueryFactory | ||
{ | ||
|
||
} |
12 changes: 0 additions & 12 deletions
12
src/Colibri/Core/Repository/GenericRepositoryQueryFactory.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Colibri\Core\Storage; | ||
|
||
use Colibri\Core\EntityManager; | ||
use Colibri\Query\Builder as QueryBuilder; | ||
|
||
/** | ||
* Class AbstractDatabasePersister | ||
* @package Colibri\Core\Persisters | ||
*/ | ||
abstract class AbstractDatabasePersister implements PersisterInterface | ||
{ | ||
|
||
/** | ||
* @var EntityManager | ||
*/ | ||
protected $entityManager; | ||
|
||
|
||
public function __construct(EntityManager $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
|
||
/** | ||
* @return QueryBuilder\Insert | ||
*/ | ||
public function createInsertQuery() | ||
{ | ||
$metadata = $this->getEntityMetadata(); | ||
$query = new QueryBuilder\Insert($this->getConnection()); | ||
|
||
$query->setTableInto($metadata->getTableName()); | ||
|
||
return $query; | ||
} | ||
|
||
/** | ||
* @return QueryBuilder\Delete | ||
*/ | ||
public function createDeleteQuery() | ||
{ | ||
$metadata = $this->getEntityMetadata(); | ||
$query = new QueryBuilder\Delete($this->getConnection()); | ||
|
||
$query->setFromTable($metadata->getTableName()); | ||
|
||
return $query; | ||
} | ||
|
||
/** | ||
* @return QueryBuilder\Update | ||
*/ | ||
public function createUpdateQuery() | ||
{ | ||
$metadata = $this->getEntityMetadata(); | ||
$query = new QueryBuilder\Update($this->getConnection()); | ||
|
||
$query->table($metadata->getTableName()); | ||
|
||
return $query; | ||
} | ||
|
||
/** | ||
* @return EntityManager | ||
*/ | ||
public function getEntityManager(): EntityManager | ||
{ | ||
return $this->entityManager; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Colibri\Core\Storage; | ||
|
||
use Colibri\Core\Entity\EntityInterface; | ||
|
||
/** | ||
* Class BasicEntityPersister | ||
* @package Colibri\Core\Storage | ||
*/ | ||
class BasicEntityPersister extends AbstractDatabasePersister | ||
{ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function create(EntityInterface $entity) | ||
{ | ||
$this->getInsertQuery(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function update(EntityInterface $entity) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function remove(EntityInterface $entity) | ||
{ | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.