コード例 #1
0
ファイル: MetadataFactory.php プロジェクト: laubosslink/lab
 /**
  * Find and configure path and namespace for the metadata collection.
  *
  * @param ClassMetadataCollection $metadata
  * @param string|null $path
  * @return void
  */
 public function findNamespaceAndPathForMetadata(ClassMetadataCollection $metadata, $path = null)
 {
     $all = $metadata->getMetadata();
     if (class_exists($all[0]->name)) {
         $r = new \ReflectionClass($all[0]->name);
         $path = $this->getBasePathForClass($r->getName(), $r->getNamespaceName(), dirname($r->getFilename()));
     } elseif (!$path) {
         throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $all[0]->name));
     }
     $metadata->setPath($path);
     $metadata->setNamespace(isset($r) ? $r->getNamespaceName() : $all[0]->name);
 }
コード例 #2
0
 /**
  * Find and configure path and namespace for the metadata collection.
  *
  * @param ClassMetadataCollection $metadata
  * @param string|null             $path
  *
  * @throws \RuntimeException When unable to determine the path
  */
 public function findNamespaceAndPathForMetadata(ClassMetadataCollection $metadata, $path = null)
 {
     $all = $metadata->getMetadata();
     if (class_exists($all[0]->name)) {
         $r = new \ReflectionClass($all[0]->name);
         $path = $this->getBasePathForClass($r->getName(), $r->getNamespaceName(), dirname($r->getFilename()));
         $ns = $r->getNamespaceName();
     } elseif ($path) {
         // Get namespace by removing the last component of the FQCN
         $nsParts = explode('\\', $all[0]->name);
         array_pop($nsParts);
         $ns = implode('\\', $nsParts);
     } else {
         throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $all[0]->name));
     }
     $metadata->setPath($path);
     $metadata->setNamespace($ns);
 }