Skip to content

Commit

Permalink
Merge branch '3.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
thewunder committed Aug 1, 2017
2 parents 0b8b2dc + 5d543f0 commit 731ebbb
Show file tree
Hide file tree
Showing 73 changed files with 2,826 additions and 995 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php
php:
- 7.0
- 5.6
- 5.5
- 7.1
install:
- composer install
services:
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Version 3.0
===========

New Features
------------
* PHP 7.1 compatibility
* Remove requirement for data objects to implement the DataObjectInterface, this makes it possible for your business
objects to be free of dependencies on the ORM.
* Allow for custom object creation and hydration behavior
* Allow for custom table and identifier conventions
* Allow for customizing the table name via the @table annotation
* Allow for a custom id column via the @identifier annotation
* Allow for custom query modifiers that change queries before they are executed
* Added convenience method for paged queries to repository base class

Breaking changes
----------------
* Dropped Compatibility for PHP versions < 7.1
* Deleted the DataObject abstract class and DataObjectInterface
* Customizing the table name is done via the @table annotation rather than overriding getTableName method
* RelationshipSaver::saveOne method signature changed for consistency and additional flexibility
* Removed relationship loading methods on repositories
* Corma now requires the fully qualified class name of the object in all cases

Version 2.1.6
===========

Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Corma is great because:
* Makes it easy to cache and avoid database queries
* Supports soft deletes
* Makes it easy to handle transactions in a Unit of Work
* Allows for customization through symfony events
* Highly customizable

Corma doesn't:

Expand All @@ -29,21 +29,26 @@ Works in MySql and PostgreSQL.

Install via Composer
--------------------

Via the command line:

composer.phar require thewunder/corma ~2.0
composer.phar require thewunder/corma ~3.0

Or add the following to the require section your composer.json:

"thewunder/corma": "~2.0"
"thewunder/corma": "~3.0"

For PHP version > 5.5 < 7.1 use Corma version ~2.0

Basic Usage
-----------
Create a DataObject
```php
namespace YourNamespace\Dataobjects;

class YourDataObject extends DataObject {
class YourDataObject {
protected $id;

//If the property name == column name on the table your_data_objects it will be saved
protected $myColumn;

Expand All @@ -63,7 +68,7 @@ class YourDataObjectRepository extends DataObjectRepository {
Create the orm and use it
```php
$db = DriverManager::getConnection(...); //see Doctrine DBAL docs
$orm = ObjectMapper::withDefaults($db, ['YourNamespace\\Dataobjects']);
$orm = ObjectMapper::withDefaults($db);

$object = $orm->create(YourDataObject::class);
//Call setters...
Expand Down Expand Up @@ -94,11 +99,13 @@ $orm->loadManyToMany($existingObjects, DifferentObject::class, 'link_table');
$orm->deleteAll($existingObjects);
```

##Documentation
Documentation
-------------

See [the wiki](https://github.com/thewunder/corma/wiki) for full documentation.

## Contributing
Contributing
------------

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"psr-4": { "Corma\\Test\\": "test/"}
},
"require": {
"php": ">=5.5",
"php": ">=7.1",
"ext-pdo" : "*",
"doctrine/dbal": "~2.0",
"symfony/event-dispatcher": ">=2.0 <4.0.0"
"symfony/event-dispatcher": ">=2.0 <4.0.0",
"minime/annotations": "~3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0",
"phpunit/phpunit": "~5.0",
"vlucas/phpdotenv": "~2.0",
"satooshi/php-coveralls": "~1.0"
},
Expand Down
120 changes: 0 additions & 120 deletions src/DataObject/DataObject.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/DataObject/DataObjectEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

class DataObjectEvent extends BaseEvent implements DataObjectEventInterface
{
/** @var DataObjectInterface */
protected $object;

public function __construct(DataObjectInterface $object)
public function __construct($object)
{
$this->object = $object;
}

/**
* @return DataObjectInterface
* @return object
*/
public function getObject()
{
Expand Down
2 changes: 1 addition & 1 deletion src/DataObject/DataObjectEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
interface DataObjectEventInterface
{
/**
* @return DataObjectInterface
* @return object
*/
public function getObject();
}
66 changes: 0 additions & 66 deletions src/DataObject/DataObjectInterface.php

This file was deleted.

43 changes: 43 additions & 0 deletions src/DataObject/Factory/BaseObjectFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace Corma\DataObject\Factory;

use Corma\DataObject\Hydrator\ObjectHydratorInterface;

abstract class BaseObjectFactory implements ObjectFactoryInterface
{
protected $reflectionClasses = [];

/**
* @var ObjectHydratorInterface
*/
protected $hydrator;


public function __construct(ObjectHydratorInterface $hydrator)
{
$this->hydrator = $hydrator;
}

public function create($class, array $dependencies = [], array $data = [])
{
if (empty($dependencies)) {
$object = new $class;
} else {
$reflectionClass = $this->getReflectionClass($class);
$object = $reflectionClass->newInstanceArgs($dependencies);
}

if (!empty($data)) {
$this->hydrator->hydrate($object, $data);
}
return $object;
}

protected function getReflectionClass($class)
{
if (isset($this->reflectionClasses[$class])) {
return $this->reflectionClasses[$class];
}
return $this->reflectionClasses[$class] = new \ReflectionClass($class);
}
}

0 comments on commit 731ebbb

Please sign in to comment.