Neos\Flow\Reflection\ClassSchema::setModelType PHP Метод

setModelType() публичный Метод

Sets the model type of the class this schema is referring to.
public setModelType ( integer $modelType ) : void
$modelType integer The model type, one of the MODELTYPE_* constants.
Результат void
    public function setModelType($modelType)
    {
        if ($modelType !== self::MODELTYPE_ENTITY && $modelType !== self::MODELTYPE_VALUEOBJECT) {
            throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
        }
        $this->modelType = $modelType;
        if ($modelType === self::MODELTYPE_VALUEOBJECT) {
            $this->identityProperties = [];
            $this->repositoryClassName = null;
        }
    }

Usage Example

 /**
  * @test
  */
 public function setModelTypeResetsIdentityPropertiesAndAggregateRootForValueObjects()
 {
     $classSchema = new ClassSchema('SomeClass');
     $classSchema->setModelType(ClassSchema::MODELTYPE_ENTITY);
     $classSchema->addProperty('foo', 'string');
     $classSchema->addProperty('bar', 'string');
     $classSchema->markAsIdentityProperty('bar');
     $classSchema->setRepositoryClassName('Some\\Repository');
     $this->assertSame(['bar' => 'string'], $classSchema->getIdentityProperties());
     $classSchema->setModelType(ClassSchema::MODELTYPE_VALUEOBJECT);
     $this->assertSame([], $classSchema->getIdentityProperties());
     $this->assertFalse($classSchema->isAggregateRoot());
 }