С версии: 1.0
Автор: Igor Golovanov (igor.golovanov@gmail.com)
Наследование: extends FilterIterator, implements Countable
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $xem = $this->getHelper('xem')->getXmlEntityManager();
     $metadatas = $xem->getMetadataFactory()->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("XmlEntities destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("XmlEntities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     if (count($metadatas)) {
         $numRepositories = 0;
         $generator = new XmlEntityRepositoryGenerator();
         foreach ($metadatas as $metadata) {
             if ($metadata->customRepositoryClassName) {
                 $output->write(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL);
                 $generator->writeDocumentRepositoryClass($metadata->customRepositoryClassName, $destPath);
                 $numRepositories++;
             }
         }
         if ($numRepositories) {
             // Outputting information message
             $output->write(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
         } else {
             $output->write('No Repository classes were found to be processed.' . PHP_EOL);
         }
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
Пример #2
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $xem = $this->getHelper('xem')->getXmlEntityManager();
     $metadatas = $xem->getMetadataFactory()->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     if (($destPath = $input->getArgument('dest-path')) === null) {
         $destPath = $xem->getConfiguration()->getProxyDir();
     }
     if (!is_dir($destPath)) {
         mkdir($destPath, 0777, true);
     }
     $destPath = realpath($destPath);
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     if (count($metadatas)) {
         foreach ($metadatas as $metadata) {
             $output->write(sprintf('Processing xml-entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
         }
         // Generating Proxies
         $xem->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
         // Outputting information message
         $output->write(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
Пример #3
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $xem = $this->getHelper('xem')->getXmlEntityManager();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setXmlEntityManager($xem);
     $cmf->setConfiguration($xem->getConfiguration());
     $metadatas = $cmf->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("XmlEntities destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("XmlEntities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     if (count($metadatas)) {
         // Create XmlEntityGenerator
         $xmlEntityGenerator = new XmlEntityGenerator();
         $xmlEntityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
         $xmlEntityGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
         $xmlEntityGenerator->setRegenerateXmlEntityIfExists($input->getOption('regenerate-xml-entities'));
         $xmlEntityGenerator->setUpdateXmlEntityIfExists($input->getOption('update-xml-entities'));
         $xmlEntityGenerator->setNumSpaces($input->getOption('num-spaces'));
         if (($extend = $input->getOption('extend')) !== null) {
             $xmlEntityGenerator->setClassToExtend($extend);
         }
         foreach ($metadatas as $metadata) {
             $output->write(sprintf('Processing xml-entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
         }
         // Generating XmlEntities
         $xmlEntityGenerator->generate($metadatas, $destPath);
         // Outputting information message
         $output->write(PHP_EOL . sprintf('XmlEntity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }