@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | CycleBootloader $cycleBootloader, |
| 38 | 38 | Registry $registry, |
| 39 | 39 | MemoryInterface $memory |
| 40 | - ) { |
|
| 40 | + ){ |
|
| 41 | 41 | $show = new ShowChanges($this->output); |
| 42 | 42 | |
| 43 | 43 | $schema = (new Compiler())->compile( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $memory->saveData('cycle', $schema); |
| 49 | 49 | |
| 50 | - if ($show->hasChanges()) { |
|
| 50 | + if ($show->hasChanges()){ |
|
| 51 | 51 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | CycleBootloader $cycleBootloader, |
| 36 | 36 | Registry $registry, |
| 37 | 37 | MemoryInterface $memory |
| 38 | - ) { |
|
| 38 | + ){ |
|
| 39 | 39 | $this->write("Updating ORM schema... "); |
| 40 | 40 | |
| 41 | 41 | $schema = (new Compiler())->compile($registry, $bootloader->getGenerators()); |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | public function boot(Container $container, FinalizerInterface $finalizer, SchemaInterface $schema = null) |
| 47 | 47 | { |
| 48 | 48 | $finalizer->addFinalizer(function () use ($container) { |
| 49 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 49 | + if ($container->hasInstance(ORMInterface::class)){ |
|
| 50 | 50 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 51 | 51 | } |
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | 54 | $container->bindInjector(Select::class, SelectInjector::class); |
| 55 | 55 | |
| 56 | - if ($schema !== null) { |
|
| 56 | + if ($schema !== null){ |
|
| 57 | 57 | $this->bootRepositories($container, $schema); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function bootRepositories(Container $container, SchemaInterface $schema) |
| 66 | 66 | { |
| 67 | - foreach ($schema->getRoles() as $role) { |
|
| 67 | + foreach ($schema->getRoles() as $role){ |
|
| 68 | 68 | $repository = $schema->define($role, SchemaInterface::REPOSITORY); |
| 69 | - if ($repository === Select\Repository::class || $repository === null) { |
|
| 69 | + if ($repository === Select\Repository::class || $repository === null){ |
|
| 70 | 70 | // default repository can not be wired |
| 71 | 71 | continue; |
| 72 | 72 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | $binding = $container->getBindings()[$repository]; |
| 78 | 78 | $container->removeBinding($repository); |
| 79 | 79 | |
| 80 | - try { |
|
| 80 | + try{ |
|
| 81 | 81 | return $orm->getRepository($role); |
| 82 | - } finally { |
|
| 82 | + }finally{ |
|
| 83 | 83 | $container->bind($repository, $binding); |
| 84 | 84 | } |
| 85 | 85 | }); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | ): ORMInterface { |
| 111 | 111 | $orm = new ORM($factory, $schema); |
| 112 | 112 | |
| 113 | - if ($promiseFactory !== null) { |
|
| 113 | + if ($promiseFactory !== null){ |
|
| 114 | 114 | return $orm->withPromiseFactory($promiseFactory); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -45,15 +45,18 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function boot(Container $container, FinalizerInterface $finalizer, SchemaInterface $schema = null) |
| 47 | 47 | { |
| 48 | - $finalizer->addFinalizer(function () use ($container) { |
|
| 49 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 48 | + $finalizer->addFinalizer(function () use ($container) |
|
| 49 | + { |
|
| 50 | + if ($container->hasInstance(ORMInterface::class)) |
|
| 51 | + { |
|
| 50 | 52 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 51 | 53 | } |
| 52 | 54 | }); |
| 53 | 55 | |
| 54 | 56 | $container->bindInjector(Select::class, SelectInjector::class); |
| 55 | 57 | |
| 56 | - if ($schema !== null) { |
|
| 58 | + if ($schema !== null) |
|
| 59 | + { |
|
| 57 | 60 | $this->bootRepositories($container, $schema); |
| 58 | 61 | } |
| 59 | 62 | } |
@@ -64,22 +67,28 @@ discard block |
||
| 64 | 67 | */ |
| 65 | 68 | public function bootRepositories(Container $container, SchemaInterface $schema) |
| 66 | 69 | { |
| 67 | - foreach ($schema->getRoles() as $role) { |
|
| 70 | + foreach ($schema->getRoles() as $role) |
|
| 71 | + { |
|
| 68 | 72 | $repository = $schema->define($role, SchemaInterface::REPOSITORY); |
| 69 | - if ($repository === Select\Repository::class || $repository === null) { |
|
| 73 | + if ($repository === Select\Repository::class || $repository === null) |
|
| 74 | + { |
|
| 70 | 75 | // default repository can not be wired |
| 71 | 76 | continue; |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | 79 | // initiate all repository dependencies using factory method forwarded to ORM |
| 75 | - $container->bindSingleton($repository, function (ORMInterface $orm) use ($role, $container, $repository) { |
|
| 80 | + $container->bindSingleton($repository, function (ORMInterface $orm) use ($role, $container, $repository) |
|
| 81 | + { |
|
| 76 | 82 | // to avoid cyclic dependency since ORM use factory to resolve needed dependencies |
| 77 | 83 | $binding = $container->getBindings()[$repository]; |
| 78 | 84 | $container->removeBinding($repository); |
| 79 | 85 | |
| 80 | - try { |
|
| 86 | + try |
|
| 87 | + { |
|
| 81 | 88 | return $orm->getRepository($role); |
| 82 | - } finally { |
|
| 89 | + } |
|
| 90 | + finally |
|
| 91 | + { |
|
| 83 | 92 | $container->bind($repository, $binding); |
| 84 | 93 | } |
| 85 | 94 | }); |
@@ -110,7 +119,8 @@ discard block |
||
| 110 | 119 | ): ORMInterface { |
| 111 | 120 | $orm = new ORM($factory, $schema); |
| 112 | 121 | |
| 113 | - if ($promiseFactory !== null) { |
|
| 122 | + if ($promiseFactory !== null) |
|
| 123 | + { |
|
| 114 | 124 | return $orm->withPromiseFactory($promiseFactory); |
| 115 | 125 | } |
| 116 | 126 | |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | public function getGenerators(): array |
| 90 | 90 | { |
| 91 | 91 | $result = []; |
| 92 | - foreach ($this->generators as $group) { |
|
| 93 | - foreach ($group as $generator) { |
|
| 94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 92 | + foreach ($this->generators as $group){ |
|
| 93 | + foreach ($group as $generator){ |
|
| 94 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 95 | 95 | $result[] = $generator; |
| 96 | - } else { |
|
| 96 | + }else{ |
|
| 97 | 97 | $result[] = $this->container->get($generator); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 110 | 110 | { |
| 111 | 111 | $schema = $memory->loadData('cycle'); |
| 112 | - if (is_null($schema)) { |
|
| 112 | + if (is_null($schema)){ |
|
| 113 | 113 | return null; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -89,11 +89,16 @@ discard block |
||
| 89 | 89 | public function getGenerators(): array |
| 90 | 90 | { |
| 91 | 91 | $result = []; |
| 92 | - foreach ($this->generators as $group) { |
|
| 93 | - foreach ($group as $generator) { |
|
| 94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 92 | + foreach ($this->generators as $group) |
|
| 93 | + { |
|
| 94 | + foreach ($group as $generator) |
|
| 95 | + { |
|
| 96 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 97 | + { |
|
| 95 | 98 | $result[] = $generator; |
| 96 | - } else { |
|
| 99 | + } |
|
| 100 | + else |
|
| 101 | + { |
|
| 97 | 102 | $result[] = $this->container->get($generator); |
| 98 | 103 | } |
| 99 | 104 | } |
@@ -109,7 +114,8 @@ discard block |
||
| 109 | 114 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 110 | 115 | { |
| 111 | 116 | $schema = $memory->loadData('cycle'); |
| 112 | - if (is_null($schema)) { |
|
| 117 | + if (is_null($schema)) |
|
| 118 | + { |
|
| 113 | 119 | return null; |
| 114 | 120 | } |
| 115 | 121 | |