Skip to content

Commit

Permalink
LeanMapperExtractor: added flag m:schemaIgnore
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Jul 28, 2023
1 parent eb62ca0 commit a08db22
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ $extractor = new Inlm\SchemaGenerator\Extractors\LeanMapperExtractor($directorie
| `m:schemaIndex` | create INDEX for column | `m:schemaIndex` |
| `m:schemaPrimary` | create PRIMARY KEY for column | `m:schemaPrimary` |
| `m:schemaUnique` | create UNIQUE INDEX for column | `m:schemaUnique` |
| `m:schemaIgnore` | ignore property | `m:schemaUnique` |

If primary column is `integer` (`@property int $id`), automatically gets `AUTO_INCREMENT`.

Expand Down
14 changes: 14 additions & 0 deletions src/LeanMapperExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ protected function generateEntity($entityClass, Generator $generator)
}

foreach ($properties as $property) {
if ($this->isPropertyIgnored($property)) {
continue;
}

if ($property->hasRelationship()) {
$relationship = $property->getRelationship();

Expand Down Expand Up @@ -300,6 +304,16 @@ protected function extractTableIndexes($tableName, Reflection\EntityReflection $
}


/**
* @return bool
*/
protected function isPropertyIgnored(Reflection\Property $property)
{
return $property->hasCustomFlag('schema-ignore')
|| $property->hasCustomFlag('schemaIgnore');
}


/**
* @param bool $isPrimaryColumn
* @param string $entityClass
Expand Down
1 change: 1 addition & 0 deletions tests/cases/lm-schema-ignore/latest/entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Book extends LeanMapper\Entity

/**
* @property int $id
* @property string $text m:schemaIgnore
*/
class Author extends LeanMapper\Entity
{
Expand Down

0 comments on commit a08db22

Please sign in to comment.