@@ -26,8 +26,8 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace ntentan\nibii\relationships; |
| 28 | 28 | |
| 29 | -use ntentan\utils\Text; |
|
| 30 | 29 | use ntentan\nibii\ORMContext; |
| 30 | +use ntentan\utils\Text; |
|
| 31 | 31 | |
| 32 | 32 | class HasManyRelationship extends \ntentan\nibii\Relationship { |
| 33 | 33 | |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | public function runSetup() { |
| 55 | 55 | if ($this->options['foreign_key'] == null) { |
| 56 | - $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id'; |
|
| 56 | + $this->options['foreign_key'] = Text::singularize($this->setupTable).'_id'; |
|
| 57 | 57 | } |
| 58 | 58 | if ($this->options['local_key'] == null) { |
| 59 | 59 | $this->options['local_key'] = $this->setupPrimaryKey[0]; |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | $relationships = $this->wrapper->getDescription()->getRelationships(); |
| 157 | 157 | $presentRelationships = []; |
| 158 | 158 | |
| 159 | - foreach($relationships ?? [] as $model => $relationship) { |
|
| 160 | - if(isset($record[$model])) { |
|
| 159 | + foreach ($relationships ?? [] as $model => $relationship) { |
|
| 160 | + if (isset($record[$model])) { |
|
| 161 | 161 | $relationship->preSave($record, $record[$model]); |
| 162 | 162 | $presentRelationships[$model] = $relationship; |
| 163 | 163 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | // Reset the data so it contains any modifications made by callbacks |
| 183 | 183 | $record = $this->wrapper->getData()[0]; |
| 184 | - foreach($presentRelationships as $model => $relationship) { |
|
| 184 | + foreach ($presentRelationships as $model => $relationship) { |
|
| 185 | 185 | $relationship->postSave($record); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use ntentan\nibii\interfaces\ModelClassResolverInterface; |
| 6 | 6 | use ntentan\nibii\interfaces\ModelJoinerInterface; |
| 7 | 7 | use ntentan\nibii\interfaces\TableNameResolverInterface; |
| 8 | -use ntentan\config\Config; |
|
| 9 | 8 | use ntentan\utils\Text; |
| 10 | 9 | |
| 11 | 10 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | $classes = [$classA['class'], $classB['class']]; |
| 42 | 42 | sort($classes); |
| 43 | - return "{$classA['namespace']}\\" . implode('', $classes); |
|
| 43 | + return "{$classA['namespace']}\\".implode('', $classes); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function getTableName($instance) { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public static function getDriverAdapterClassName($driver = false) { |
| 53 | 53 | if ($driver) { |
| 54 | - return __NAMESPACE__ . '\adapters\\' . Text::ucamelize($driver) . 'Adapter'; |
|
| 54 | + return __NAMESPACE__.'\adapters\\'.Text::ucamelize($driver).'Adapter'; |
|
| 55 | 55 | } |
| 56 | 56 | throw new NibiiException("Please specify a driver"); |
| 57 | 57 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $valueFields[] = ":{$field}"; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return "INSERT INTO " . $table . |
|
| 33 | - " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")"; |
|
| 32 | + return "INSERT INTO ".$table. |
|
| 33 | + " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")"; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function getBulkUpdateQuery($data, $parameters) { |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return "UPDATE " . |
|
| 75 | - $model->getDBStoreInformation()['quoted_table'] . |
|
| 76 | - " SET " . implode(', ', $valueFields) . |
|
| 77 | - " WHERE " . implode(' AND ', $conditions); |
|
| 74 | + return "UPDATE ". |
|
| 75 | + $model->getDBStoreInformation()['quoted_table']. |
|
| 76 | + " SET ".implode(', ', $valueFields). |
|
| 77 | + " WHERE ".implode(' AND ', $conditions); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function getSelectQuery($parameters) { |
@@ -26,8 +26,8 @@ |
||
| 26 | 26 | |
| 27 | 27 | namespace ntentan\nibii; |
| 28 | 28 | |
| 29 | -use ntentan\utils\validator\Validation; |
|
| 30 | 29 | use ntentan\panie\Container; |
| 30 | +use ntentan\utils\validator\Validation; |
|
| 31 | 31 | |
| 32 | 32 | class UniqueValidation extends Validation |
| 33 | 33 | { |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return $this->evaluateResult( |
| 71 | - $field, $testItem->count() === 0, "The value of " . implode(', ', $field['name']) . " must be unique" |
|
| 71 | + $field, $testItem->count() === 0, "The value of ".implode(', ', $field['name'])." must be unique" |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @method |
| 152 | - * @param type $name |
|
| 152 | + * @param string $name |
|
| 153 | 153 | * @param type $arguments |
| 154 | 154 | * @return type |
| 155 | 155 | */ |
@@ -178,6 +178,10 @@ discard block |
||
| 178 | 178 | return $this->retrieveItem($name); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | + /** |
|
| 182 | + * @param Relationship[] $relationships |
|
| 183 | + * @param integer $depth |
|
| 184 | + */ |
|
| 181 | 185 | private function expandArrayValue($array, $relationships, $depth, $index = null) |
| 182 | 186 | { |
| 183 | 187 | foreach ($relationships as $name => $relationship) { |
@@ -365,6 +369,9 @@ discard block |
||
| 365 | 369 | |
| 366 | 370 | } |
| 367 | 371 | |
| 372 | + /** |
|
| 373 | + * @param string $id |
|
| 374 | + */ |
|
| 368 | 375 | public function postSaveCallback($id) |
| 369 | 376 | { |
| 370 | 377 | |
@@ -393,7 +400,7 @@ discard block |
||
| 393 | 400 | |
| 394 | 401 | /** |
| 395 | 402 | * |
| 396 | - * @return DataAdapter |
|
| 403 | + * @return DriverAdapter |
|
| 397 | 404 | */ |
| 398 | 405 | public function getAdapter() |
| 399 | 406 | { |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $this->table = $table['table']; |
| 87 | 87 | $this->schema = $table['schema']; |
| 88 | 88 | } |
| 89 | - $this->quotedTable = ($this->schema ? "{$driver->quoteIdentifier($this->schema)}." : "") . $driver->quoteIdentifier($this->table); |
|
| 90 | - $this->unquotedTable = ($this->schema ? "{$this->schema}." : "") . $this->table; |
|
| 89 | + $this->quotedTable = ($this->schema ? "{$driver->quoteIdentifier($this->schema)}." : "").$driver->quoteIdentifier($this->table); |
|
| 90 | + $this->unquotedTable = ($this->schema ? "{$this->schema}." : "").$this->table; |
|
| 91 | 91 | $this->adapter->setModel($this, $this->quotedTable); |
| 92 | 92 | foreach ($this->behaviours as $behaviour) { |
| 93 | 93 | $behaviourInstance = $this->getComponentInstance($behaviour); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $this->initialize(); |
| 112 | 112 | return $this->context->getCache()->read( |
| 113 | - (new \ReflectionClass($this))->getName() . '::desc', function() { |
|
| 113 | + (new \ReflectionClass($this))->getName().'::desc', function() { |
|
| 114 | 114 | return $this->container->resolve(ModelDescription::class, ['model' => $this]); |
| 115 | 115 | } |
| 116 | 116 | ); |
@@ -11,5 +11,8 @@ |
||
| 11 | 11 | |
| 12 | 12 | interface ModelFactoryInterface |
| 13 | 13 | { |
| 14 | + /** |
|
| 15 | + * @param string $name |
|
| 16 | + */ |
|
| 14 | 17 | public function createModel($name, $context); |
| 15 | 18 | } |
| 16 | 19 | \ No newline at end of file |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use ntentan\atiaa\DbContext; |
| 6 | 6 | use ntentan\kaikai\Cache; |
| 7 | -use ntentan\panie\Container; |
|
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * A collection of utility methods used as helpers for loading |