Skip to content

Commit 4a2ac70

Browse files
Merge pull request #34 from laravel-doctrine/master
1.0.0
2 parents 31303d8 + 4d4cf8f commit 4a2ac70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1278
-286
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ composer.lock
44
.DS_Store
55
.php_cs.cache
66

7+
/tests/Stubs/storage/framework/views/*
8+
!/tests/Stubs/storage/framework/views/.gitkeep
9+
/tests/Stubs/storage/doctrine.generated.php
710
.idea
811
laravel-doctrine-orm.iml

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ return Symfony\CS\Config\Config::create()
88
->setUsingCache(true)
99
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
1010
->fixers(array(
11-
'psr0',
11+
'psr4',
1212
'encoding',
1313
'short_tag',
1414
'blankline_after_open_tag',

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ language: php
33
php:
44
- 5.5
55
- 5.6
6+
- 7.0
7+
- hhvm
68

79
before_script:
810
- travis_retry composer self-update
@@ -12,6 +14,8 @@ after_script:
1214
- wget https://scrutinizer-ci.com/ocular.phar
1315
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
1416

17+
sudo: false
18+
1519
script: phpunit --coverage-clover=coverage.clover
1620

1721
matrix:

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<img src="https://cloud.githubusercontent.com/assets/7728097/9831648/1827b704-5960-11e5-982d-98c8fc8dcacd.jpg"/>
44

5-
[![GitHub release](https://img.shields.io/github/release/laravel-doctrine/orm.svg?style=flat)](https://packagist.org/packages/laravel-doctrine/orm)
6-
[![Travis](https://img.shields.io/travis/laravel-doctrine/orm.svg?style=flat)](https://travis-ci.org/laravel-doctrine/orm)
7-
[![Scrutinizer](https://img.shields.io/scrutinizer/g/laravel-doctrine/orm.svg?style=flat)](https://github.com/laravel-doctrine/orm)
8-
[![Packagist](https://img.shields.io/packagist/dd/laravel-doctrine/orm.svg?style=flat)](https://packagist.org/packages/laravel-doctrine/orm)
9-
[![Packagist](https://img.shields.io/packagist/dm/laravel-doctrine/orm.svg?style=flat)](https://packagist.org/packages/laravel-doctrine/orm)
10-
[![Packagist](https://img.shields.io/packagist/dt/laravel-doctrine/orm.svg?style=flat)](https://packagist.org/packages/laravel-doctrine/orm)
5+
[![GitHub release](https://img.shields.io/github/release/laravel-doctrine/orm.svg?style=flat-square)](https://packagist.org/packages/laravel-doctrine/orm)
6+
[![Travis](https://img.shields.io/travis/laravel-doctrine/orm.svg?style=flat-square)](https://travis-ci.org/laravel-doctrine/orm)
7+
[![StyleCI](https://styleci.io/repos/39036008/shield)](https://styleci.io/repos/39036008)
8+
[![Scrutinizer](https://img.shields.io/scrutinizer/g/laravel-doctrine/orm.svg?style=flat-square)](https://github.com/laravel-doctrine/orm)
9+
[![Packagist](https://img.shields.io/packagist/dm/laravel-doctrine/orm.svg?style=flat-square)](https://packagist.org/packages/laravel-doctrine/orm)
10+
[![Packagist](https://img.shields.io/packagist/dt/laravel-doctrine/orm.svg?style=flat-square)](https://packagist.org/packages/laravel-doctrine/orm)
1111

1212
*A drop-in Doctrine ORM 2 implementation for Laravel 5+*
1313

@@ -53,13 +53,13 @@ Require this package
5353
After adding the package, add the ServiceProvider to the providers array in `config/app.php`
5454

5555
```php
56-
'LaravelDoctrine\ORM\DoctrineServiceProvider',
56+
LaravelDoctrine\ORM\DoctrineServiceProvider::class,
5757
```
5858

5959
Optionally you can register the EntityManager facade:
6060

6161
```php
62-
'EntityManager' => 'LaravelDoctrine\ORM\Facades\EntityManager'
62+
'EntityManager' => LaravelDoctrine\ORM\Facades\EntityManager::class
6363
```
6464

6565
To publish the config use:

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"illuminate/pagination": "~5.1",
2727
"illuminate/support": "~5.1",
2828
"illuminate/validation": "~5.1",
29-
"illuminate/view": "~5.1"
29+
"illuminate/view": "~5.1",
30+
"symfony/serializer": "^2.7"
3031
},
3132
"require-dev": {
3233
"phpunit/phpunit": "~4.0",
@@ -46,6 +47,9 @@
4647
]
4748
},
4849
"suggest": {
50+
"laravel-doctrine/acl": "to integrate Doctrine roles & permissions with Laravel's Authorization system (~1.0)",
51+
"laravel-doctrine/extensions": "to add Behavioral and Query/Type Extensions for Laravel Doctrine (~1.0)",
52+
"laravel-doctrine/migrations": "to add support for migrations in Laravel Doctrine (~1.0)",
4953
"yajra/laravel-oci8": "Support for Laravel native queue and session database drivers in Oracle (~2.0)."
5054
}
5155
}

src/Auth/Authenticatable.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ trait Authenticatable
1414
*/
1515
protected $rememberToken;
1616

17+
/**
18+
* Get the column name for the primary key
19+
* @return string
20+
*/
21+
public function getAuthIdentifierName()
22+
{
23+
return 'id';
24+
}
25+
1726
/**
1827
* Get the unique identifier for the user.
1928
* @return mixed
@@ -25,15 +34,6 @@ public function getAuthIdentifier()
2534
return $this->{$name};
2635
}
2736

28-
/**
29-
* Get the column name for the primary key
30-
* @return string
31-
*/
32-
public function getAuthIdentifierName()
33-
{
34-
return 'id';
35-
}
36-
3737
/**
3838
* @return string
3939
*/

src/Auth/CanResetPassword.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Auth/Passwords/PasswordResetServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function registerTokenRepository()
7272
return new DoctrineTokenRepository(
7373
$this->app->make(ManagerRegistry::class)->getManagerForClass(PasswordReminder::class),
7474
$app['config']['app.key'],
75-
$app['config']->get('auth.reminder.expire', 60)
75+
$app['config']->get('auth.password.expire', 60)
7676
);
7777
});
7878
}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<?php
2+
3+
namespace LaravelDoctrine\ORM\Console\ConfigMigrations;
4+
5+
use Illuminate\Contracts\View\Factory;
6+
use LaravelDoctrine\ORM\Utilities\ArrayUtil;
7+
8+
class AtrauzziMigrator implements ConfigurationMigrator
9+
{
10+
/**
11+
* @var Factory
12+
*/
13+
protected $viewFactory;
14+
15+
/**
16+
* @param Factory $viewFactory
17+
*/
18+
public function __construct(Factory $viewFactory)
19+
{
20+
$this->viewFactory = $viewFactory;
21+
$this->viewFactory->addNamespace('atrauzzi', realpath(__DIR__ . '/templates/atrauzzi'));
22+
$this->viewFactory->addNamespace('laraveldoctrine', realpath(__DIR__ . '/templates/laraveldoctrine'));
23+
}
24+
25+
/**
26+
* Convert a configuration array from another laravel-doctrine project in to a string representation of a php array configuration for this project
27+
*
28+
* @param array $sourceArray
29+
*
30+
* @return string
31+
*/
32+
public function convertConfiguration($sourceArray)
33+
{
34+
$dqls = $this->convertDQL($sourceArray);
35+
$cache = $this->convertCache($sourceArray);
36+
$customTypes = $this->convertCustomTypes($sourceArray);
37+
$managers = [$this->convertManager($sourceArray)];
38+
39+
$results = $this->viewFactory->make('laraveldoctrine.master', [
40+
'managers' => $managers,
41+
'cache' => $cache,
42+
'dqls' => $dqls,
43+
'customTypes' => $customTypes
44+
])->render();
45+
46+
return $this->unescape($results);
47+
}
48+
49+
/**
50+
* @param $sourceArray
51+
*
52+
* @return string
53+
*/
54+
public function convertManager($sourceArray)
55+
{
56+
$proxySettings = ArrayUtil::get($sourceArray['proxy_classes']);
57+
$defaultRepo = ArrayUtil::get($sourceArray['default_repository']);
58+
$namespaces = [];
59+
$connection = ArrayUtil::get($sourceArray['default']);
60+
61+
// Non default configuration
62+
if (count($sourceArray['metadata']) > 1) {
63+
$hasNamespaces = false;
64+
$driver = null;
65+
$sameDriver = true;
66+
67+
foreach ($sourceArray['metadata'] as $key => $item) {
68+
if (is_null($driver)) {
69+
if (is_array($item)) {
70+
$driver = $item['driver'];
71+
} elseif ($key == 'driver') {
72+
$driver = $item;
73+
}
74+
} else {
75+
if (is_array($item) && $item['driver'] != $driver) {
76+
$sameDriver = false;
77+
}
78+
}
79+
if (is_array($item) && isset($item['namespace'])) {
80+
$hasNamespaces = true;
81+
}
82+
}
83+
// Only do this if all the same driver
84+
if ($hasNamespaces && $sameDriver) {
85+
$driver = $sourceArray['metadata'][0]['driver'];
86+
87+
// Convert each metadata entry into a namespace entry
88+
foreach ($sourceArray['metadata'] as $item) {
89+
if (isset($item['alias'])) {
90+
$namespaces[$item['alias']] = $item['namespace'];
91+
} else {
92+
array_push($namespaces, $item['namespace']);
93+
}
94+
}
95+
// Only specifying one non-default EM
96+
} else {
97+
if (isset($sourceArray['metadata']['namespace'])) {
98+
if (isset($sourceArray['metadata']['alias'])) {
99+
$namespaces[$sourceArray['metadata']['alias']] = $sourceArray['metadata']['namespace'];
100+
} else {
101+
$namespaces[] = $sourceArray['metadata']['namespace'];
102+
}
103+
}
104+
}
105+
// One EM, default
106+
} else {
107+
$driver = $sourceArray['metadata']['driver'];
108+
}
109+
110+
$results = $this->viewFactory->make('atrauzzi.manager', [
111+
'namespaces' => $namespaces,
112+
'proxySettings' => $proxySettings,
113+
'defaultRepo' => $defaultRepo,
114+
'driver' => $driver,
115+
'connection' => $connection
116+
])->render();
117+
118+
return $this->unescape($results);
119+
}
120+
121+
/**
122+
* @param $sourceArray
123+
*
124+
* @return string
125+
*/
126+
public function convertCustomTypes($sourceArray)
127+
{
128+
$results = $this->viewFactory->make('atrauzzi.customTypes', [
129+
'sourceArray' => $sourceArray
130+
])->render();
131+
132+
return $this->unescape($results);
133+
}
134+
135+
/**
136+
* Convert a cache section from mitchellvanw/laravel-doctrine to a string representation of a php array configuration for a cache section for this project
137+
*
138+
* @param array $sourceArray
139+
*
140+
* @return string
141+
*/
142+
public function convertCache($sourceArray)
143+
{
144+
if (isset($sourceArray['cache']['provider'])) {
145+
$cacheProvider = ArrayUtil::get($sourceArray['cache']['provider']);
146+
$results = $this->viewFactory->make('atrauzzi.cache', [
147+
'cacheProvider' => $cacheProvider,
148+
'extras' => count($sourceArray['cache']) > 1
149+
//if user is mimicking cache arrays here we need to tell them to move these to cache.php
150+
])->render();
151+
152+
return $this->unescape($results);
153+
}
154+
155+
return null;
156+
}
157+
158+
/**
159+
* Convert the dql sections from the entity managers in a configuration from atruazzi/laravel-doctrine into a string representation of a php array configuration for custom string/numeric/datetime functions
160+
* Returns null if no dql sections were found.
161+
*
162+
* @param $sourceArray
163+
*
164+
* @return null|string
165+
*/
166+
public function convertDQL($sourceArray)
167+
{
168+
$results = $this->viewFactory->make('atrauzzi.dql', ['dql' => $sourceArray])->render();
169+
170+
return $this->unescape($results);
171+
}
172+
173+
/**
174+
* @param $results
175+
*
176+
* @return string
177+
*/
178+
protected function unescape($results)
179+
{
180+
return html_entity_decode($results, ENT_QUOTES);
181+
}
182+
}

src/Console/ConfigMigrations/ConfigurationMigrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaravelDoctrine\ORM\ConfigMigrations;
3+
namespace LaravelDoctrine\ORM\Console\ConfigMigrations;
44

55
use Illuminate\Contracts\View\Factory;
66

0 commit comments

Comments
 (0)