/** * @param ClassMetadataInfo $metadata * @param string $outputDir * @param Closure $collectionNameBuilder */ public function generate(ClassMetadataInfo $metadata, $outputDir, Closure $collectionNameBuilder) { $tpl = file_get_contents(CodeGeneratorHelper::absPath(EntityCollectionTemplate::class, RootPath::path())); $tplNs = CodeGeneratorHelper::ns(EntityCollectionTemplate::class); $tplSimpleName = CodeGeneratorHelper::simpleName(EntityCollectionTemplate::class); $entityFqcn = CodeGeneratorHelper::simpleName(EntityFqcn::class); $collectionClassName = $collectionNameBuilder($metadata->getName()); $code = CodeGeneratorHelper::render($tpl, array($tplNs => CodeGeneratorHelper::ns($collectionClassName), $tplSimpleName => CodeGeneratorHelper::simpleName($collectionClassName), $entityFqcn => CodeGeneratorHelper::fqn($metadata->getName()))); CodeGeneratorHelper::save($collectionClassName, $code, $outputDir); }
protected function generateQueryCollectionCondClass($metadatas, ClassMetadataInfo $metadata) { $code = file_get_contents(CodeGeneratorHelper::absPath(____QueryCondSimpleClassName____::class, RootPath::path())); $code = CodeGeneratorHelper::render($code, [__NAMESPACE__ => $metadata->getName()]); $code = CodeGeneratorHelper::render($code, ['/* <code> */' => $this->generateCondCodeBody($metadatas, $metadata)]); $code = CodeGeneratorHelper::render($code, array('QueryCondSimpleClassName' => CodeGeneratorHelper::simpleName($this->helper->getQueryCollectionCondClassNameByEntityClass($metadata->getName())), 'TableName' => $metadata->getTableName()), self::KEY_TEMPLATE); return $code; }