PHP Класс Doctrine\ODM\MongoDB\Tools\DocumentGenerator

[php] $classes = $dm->getClassMetadataInfoFactory()->getAllMetadata(); $generator = new \Doctrine\ODM\MongoDB\Tools\DocumentGenerator(); $generator->setGenerateAnnotations(true); $generator->setGenerateStubMethods(true); $generator->setRegenerateDocumentIfExists(false); $generator->setUpdateDocumentIfExists(true); $generator->generate($classes, '/path/to/generate/documents');
С версии: 1.0
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
generate ( array $metadatas, string $outputDirectory ) : void Generate and write document classes for the given array of ClassMetadataInfo instances
generateDocumentClass ( ClassMetadataInfo $metadata ) : string Generate a PHP5 Doctrine 2 document class from the given ClassMetadataInfo instance
generateUpdatedDocumentClass ( ClassMetadataInfo $metadata, string $path ) : string Generate the updated code for the given ClassMetadataInfo and document at path
setBackupExisting ( boolean $bool ) Sets a value indicating whether existing documents will be backed up.
setClassToExtend ( string $classToExtend ) : void Set the name of the class the generated classes should extend from
setExtension ( string $extension ) : void Set the extension to use when writing php files to disk
setGenerateAnnotations ( boolean $bool ) : void Set whether or not to generate annotations for the document
setGenerateStubMethods ( boolean $bool ) : void Set whether or not to generate stub methods for the document
setNumSpaces ( integer $numSpaces ) : void Set the number of spaces the exported class should have
setRegenerateDocumentIfExists ( boolean $bool ) : void Set whether or not to regenerate the document if it exists
setUpdateDocumentIfExists ( boolean $bool ) : void Set whether or not to try and update the document if it already exists
writeDocumentClass ( ClassMetadataInfo $metadata, string $outputDirectory ) : void Generated and write document class to disk for the given ClassMetadataInfo instance

Защищенные методы

Метод Описание
getTraits ( ClassMetadataInfo $metadata ) : array
isAssociationNullable ( array $fieldMapping ) : boolean

Приватные методы

Метод Описание
extendsClass ( )
generateAssociationMappingPropertyDocBlock ( array $fieldMapping )
generateChangeTrackingPolicyAnnotation ( ClassMetadataInfo $metadata )
generateDefaultDiscriminatorValueAnnotation ( ClassMetadataInfo $metadata )
generateDiscriminatorFieldAnnotation ( ClassMetadataInfo $metadata )
generateDiscriminatorMapAnnotation ( ClassMetadataInfo $metadata )
generateDocumentAssociationMappingProperties ( ClassMetadataInfo $metadata )
generateDocumentBody ( ClassMetadataInfo $metadata )
generateDocumentClassName ( ClassMetadataInfo $metadata )
generateDocumentConstructor ( ClassMetadataInfo $metadata )
generateDocumentDocBlock ( ClassMetadataInfo $metadata )
generateDocumentFieldMappingProperties ( ClassMetadataInfo $metadata )
generateDocumentImports ( )
generateDocumentLifecycleCallbackMethods ( ClassMetadataInfo $metadata )
generateDocumentNamespace ( ClassMetadataInfo $metadata )
generateDocumentStubMethod ( ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null )
generateDocumentStubMethods ( ClassMetadataInfo $metadata )
generateFieldMappingPropertyDocBlock ( array $fieldMapping, ClassMetadataInfo $metadata )
generateInheritanceAnnotation ( ClassMetadataInfo $metadata )
generateLifecycleCallbackMethod ( $name, $methodName, ClassMetadataInfo $metadata )
getChangeTrackingPolicyString ( $policy )
getClassName ( ClassMetadataInfo $metadata )
getClassToExtend ( )
getClassToExtendName ( )
getIdGeneratorTypeString ( $type )
getInheritanceTypeString ( $type )
getNamespace ( ClassMetadataInfo $metadata )
hasMethod ( $method, ClassMetadataInfo $metadata )
hasNamespace ( ClassMetadataInfo $metadata )
hasProperty ( $property, ClassMetadataInfo $metadata )
parseTokensInDocumentFile ( string $path )
prefixCodeWithSpaces ( $code, $num = 1 )

Описание методов

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

Generate and write document classes for the given array of ClassMetadataInfo instances
public generate ( array $metadatas, string $outputDirectory ) : void
$metadatas array
$outputDirectory string
Результат void

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

Generate a PHP5 Doctrine 2 document class from the given ClassMetadataInfo instance
public generateDocumentClass ( ClassMetadataInfo $metadata ) : string
$metadata Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo
Результат string $code

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

Generate the updated code for the given ClassMetadataInfo and document at path
public generateUpdatedDocumentClass ( ClassMetadataInfo $metadata, string $path ) : string
$metadata Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo
$path string
Результат string $code;

getTraits() защищенный Метод

protected getTraits ( ClassMetadataInfo $metadata ) : array
$metadata Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo
Результат array

isAssociationNullable() защищенный Метод

protected isAssociationNullable ( array $fieldMapping ) : boolean
$fieldMapping array
Результат boolean

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

Sets a value indicating whether existing documents will be backed up.
public setBackupExisting ( boolean $bool )
$bool boolean True to backup existing document, false to overwrite.

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

Set the name of the class the generated classes should extend from
public setClassToExtend ( string $classToExtend ) : void
$classToExtend string Class name.
Результат void

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

Set the extension to use when writing php files to disk
public setExtension ( string $extension ) : void
$extension string
Результат void

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

Set whether or not to generate annotations for the document
public setGenerateAnnotations ( boolean $bool ) : void
$bool boolean
Результат void

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

Set whether or not to generate stub methods for the document
public setGenerateStubMethods ( boolean $bool ) : void
$bool boolean
Результат void

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

Set the number of spaces the exported class should have
public setNumSpaces ( integer $numSpaces ) : void
$numSpaces integer
Результат void

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

Set whether or not to regenerate the document if it exists
public setRegenerateDocumentIfExists ( boolean $bool ) : void
$bool boolean
Результат void

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

Set whether or not to try and update the document if it already exists
public setUpdateDocumentIfExists ( boolean $bool ) : void
$bool boolean
Результат void

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

Generated and write document class to disk for the given ClassMetadataInfo instance
public writeDocumentClass ( ClassMetadataInfo $metadata, string $outputDirectory ) : void
$metadata Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo
$outputDirectory string
Результат void