File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed
Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -163,4 +163,14 @@ public function remove(object $object): self
163163 $ this ->detach ($ object );
164164 return $ this ;
165165 }
166+
167+ public static function fromArray (array $ data ): self
168+ {
169+ return new self ($ data );
170+ }
171+
172+ public static function fromObjectStorage (ObjectStorage $ storage ): self
173+ {
174+ return new self ($ storage ->toArray ());
175+ }
166176}
Original file line number Diff line number Diff line change 22
33namespace Michel \PaperORM \Michel \Package ;
44
5- use Michel \Michel \ Package \PackageInterface ;
5+ use Michel \Package \PackageInterface ;
66use Michel \PaperORM \Collector \EntityDirCollector ;
77use Michel \PaperORM \Command \DatabaseCreateCommand ;
88use Michel \PaperORM \Command \DatabaseDropCommand ;
@@ -30,7 +30,7 @@ public function getDefinitions(): array
3030 );
3131 $ logger = $ container ->get ('paper.orm.logger ' );
3232 if ($ logger ) {
33- $ paperConf ->withLogger ($ container -> get ( ' paper.orm. logger' ) );
33+ $ paperConf ->withLogger ($ logger );
3434 }
3535 return $ paperConf ;
3636 },
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ final class MigrationDirectory
1010 public function __construct (string $ dir )
1111 {
1212 if (!is_dir ($ dir )) {
13- throw new \InvalidArgumentException ("Directory ' $ dir' does not exist. " );
13+ if (!mkdir ($ dir , 0777 , true )) {
14+ throw new \InvalidArgumentException ("Cannot create directory ' $ dir', check permissions. " );
15+ }
1416 }
1517
1618 if (!is_writable ($ dir )) {
Original file line number Diff line number Diff line change @@ -424,14 +424,14 @@ public function buildSqlQuery(): JoinQL
424424 $ value = $ value ->getPrimaryKeyValue ();
425425 }elseif (is_iterable ($ value )) {
426426 $ values = [];
427- foreach ($ value as $ k => $ v ) {
427+ foreach ($ value as $ v ) {
428428 if ($ v instanceof EntityInterface) {
429- $ values [$ k ] = $ v ->getPrimaryKeyValue ();
429+ $ values [] = $ v ->getPrimaryKeyValue ();
430430 }else {
431- $ values [$ k ] = $ v ;
431+ $ values [] = $ v ;
432432 }
433433 }
434- $ value = $ values ;
434+ $ value = implode ( ' , ' , $ values) ;
435435 }
436436
437437 $ joinQl ->setParam ($ key , $ value );
You can’t perform that action at this time.
0 commit comments