コード例 #1
0
 public function generate(BundleInterface $bundle, ClassMetadata $class_metadata)
 {
     $document_name = explode('\\', $class_metadata->getName());
     $document_name = array_pop($document_name);
     // Controller Generator
     $dir = $bundle->getPath();
     $controllerFile = $dir . '/Controller/' . $document_name . 'sController.php';
     if (file_exists($controllerFile)) {
         throw new \RuntimeException(sprintf('Controller "%s" already exists', $document_name));
     }
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle->getName(), 'controller' => $document_name . 'sController', 'document_name' => $document_name);
     $this->renderFile('controller/Controller.php.twig', $controllerFile, $parameters);
     // FormType Generator
     $formTypeFile = $dir . '/Form/' . $document_name . 'Type.php';
     if (file_exists($formTypeFile)) {
         throw new \RuntimeException(sprintf('Form Type "%s" already exists', $document_name));
     }
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle->getName(), 'formtype' => $document_name . 'Type', 'document' => $class_metadata->getName(), 'fields' => $class_metadata->getFieldNames());
     $this->renderFile('form/FormType.php.twig', $formTypeFile, $parameters);
 }
コード例 #2
0
 /**
  * @param ClassMetadata $metadata
  *
  * @return string[]
  */
 private function getProperties(ClassMetadata $metadata)
 {
     return array_merge($metadata->getFieldNames(), array_map(function (array $mapping) {
         return $mapping['fieldName'];
     }, $metadata->getEmbeddedFieldsMappings()));
 }