getNamespace() public method

Gets the Bundle namespace.
public getNamespace ( ) : string
return string The Bundle namespace
Ejemplo n.º 1
0
 /**
  * Register an installer service
  *
  * @param BaseBundle $bundleInfos
  * @param string $type Type (install, update or uninstall)
  * @param string $class Class (Install, Update or Uninstall)
  */
 protected function registerInstallerService(BaseBundle $bundleInfos, $type, $class)
 {
     $serviceId = strtolower($bundleInfos->getName()) . '.installer.' . $type;
     $fullyQualifiedClass = $bundleInfos->getNamespace() . '\\Service\\Install\\' . $class;
     $serviceOptions = array('calls' => array(array('setContainer' => array('@service_container'))), 'tags' => array(array('name' => 'bundle.' . $type)));
     $this->registerService($bundleInfos->getName(), $serviceId, $fullyQualifiedClass, $serviceOptions);
 }
 /**
  * @param Bundle          $bundle
  * @param OutputInterface $output
  */
 public function generate(Bundle $bundle, OutputInterface $output)
 {
     // This is needed so the renderFile method will search for the files
     // in the correct location
     $this->setSkeletonDirs(array($this->fullSkeletonDir));
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle);
     $this->generateBehatTests($bundle, $output, $parameters);
 }
 /**
  * @param Bundle          $bundle     The bundle
  * @param string          $prefix     The prefix
  * @param string          $rootDir    The root directory
  * @param string          $createPage Create data fixtures or not
  * @param OutputInterface $output
  */
 public function generate(Bundle $bundle, $prefix, $rootDir, $createPage, OutputInterface $output)
 {
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle, 'prefix' => GeneratorUtils::cleanPrefix($prefix));
     $this->generateEntities($bundle, $parameters, $output);
     $this->generateTemplates($bundle, $parameters, $rootDir, $output);
     if ($createPage) {
         $this->generateFixtures($bundle, $parameters, $output);
     }
 }
 /**
  * Return the package prefix for a given bundle.
  *
  * @param Bundle $bundle
  * @param string $baseDirectory The base directory to exclude from prefix.
  *
  * @return string
  */
 protected function getPackagePrefix(Bundle $bundle, $baseDirectory = '')
 {
     $parts = explode(DIRECTORY_SEPARATOR, realpath($bundle->getPath()));
     $length = count(explode('\\', $bundle->getNamespace())) * -1;
     $prefix = implode(DIRECTORY_SEPARATOR, array_slice($parts, 0, $length));
     $prefix = ltrim(str_replace($baseDirectory, '', $prefix), DIRECTORY_SEPARATOR);
     if (!empty($prefix)) {
         $prefix = str_replace(DIRECTORY_SEPARATOR, '.', $prefix) . '.';
     }
     return $prefix;
 }
Ejemplo n.º 5
0
 /**
  * @param Bundle $bundle
  * @return ClassMetadata[]
  */
 protected function getBundleMetadata(Bundle $bundle)
 {
     $bundleMetadata = [];
     $metadata = $this->em->getMetadataFactory()->getAllMetadata();
     /** @var ClassMetadata $meta */
     foreach ($metadata as $meta) {
         if (strpos($meta->getName(), $bundle->getNamespace()) !== false) {
             $bundleMetadata[] = $meta;
         }
     }
     return $bundleMetadata;
 }
Ejemplo n.º 6
0
 /**
  * Writes a bundle migration class for a given driver.
  *
  * @param \Symfony\Component\HttpKernel\Bundle\Bundle   $bundle
  * @param string                                        $driverName
  * @param string                                        $version
  * @param array                                         $queries
  */
 public function writeMigrationClass(Bundle $bundle, $driverName, $version, array $queries)
 {
     $targetDir = "{$bundle->getPath()}/Migrations/{$driverName}";
     $class = "Version{$version}";
     $namespace = "{$bundle->getNamespace()}\\Migrations\\{$driverName}";
     $classFile = "{$targetDir}/{$class}.php";
     if (!$this->fileSystem->exists($targetDir)) {
         $this->fileSystem->mkdir($targetDir);
     }
     $content = $this->twigEngine->render('ClarolineMigrationBundle::migration_class.html.twig', array('namespace' => $namespace, 'class' => $class, 'upQueries' => $queries[Generator::QUERIES_UP], 'downQueries' => $queries[Generator::QUERIES_DOWN]));
     $this->fileSystem->touch($classFile);
     file_put_contents($classFile, $content);
 }
 /**
  * Load the generators confirming to default naming rules in the given bundle.
  * @param Bundle $bundle
  */
 private function loadGeneratorsForBundle(Bundle $bundle)
 {
     $dir = "{$bundle->getPath()}/Generator";
     if (is_dir($dir)) {
         $finder = new Finder();
         $finder->files()->name('*Generator.php')->in($dir);
         $prefix = $bundle->getNamespace() . '\\Generator';
         /** @var SplFileInfo $file */
         foreach ($finder as $file) {
             $this->loadGeneratorInBundle($file, $prefix);
         }
     }
 }
Ejemplo n.º 8
0
 private function getBundleTables(Bundle $bundle, array $metadata)
 {
     $bundleTables = array('tables' => array(), 'joinTables' => array());
     foreach ($metadata as $entityMetadata) {
         if (0 === strpos($entityMetadata->name, $bundle->getNamespace())) {
             $bundleTables[] = $entityMetadata->getTableName();
             foreach ($entityMetadata->associationMappings as $association) {
                 if (isset($association['joinTable']['name'])) {
                     $bundleTables[] = $association['joinTable']['name'];
                 }
             }
         }
     }
     return $bundleTables;
 }
 /**
  * @param Bundle          $bundle The bundle
  * @param string          $entity
  * @param string          $prefix The prefix
  * @param bool            $dummydata
  * @param OutputInterface $output
  */
 public function generate(Bundle $bundle, $entity, $prefix, $dummydata, OutputInterface $output)
 {
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle, 'prefix' => GeneratorUtils::cleanPrefix($prefix), 'entity_class' => $entity);
     $this->generateEntities($bundle, $entity, $parameters, $output);
     $this->generateRepositories($bundle, $entity, $parameters, $output);
     $this->generateForm($bundle, $entity, $parameters, $output);
     $this->generateAdminList($bundle, $entity, $parameters, $output);
     $this->generateController($bundle, $entity, $parameters, $output);
     $this->generatePageTemplateConfigs($bundle, $entity, $parameters, $output);
     $this->generateTemplates($bundle, $entity, $parameters, $output);
     $this->generateRouting($bundle, $entity, $parameters, $output);
     $this->generateMenu($bundle, $entity, $parameters, $output);
     $this->generateServices($bundle, $entity, $parameters, $output);
     if ($dummydata) {
         $this->generateFixtures($bundle, $entity, $parameters, $output);
     }
 }
 /**
  * @param Bundle        $bundle     The bundle
  * @param string        $entityName The entity name
  * @param ClassMetadata $metadata   The meta data
  *
  * @throws \RuntimeException
  */
 public function generateAdminType(Bundle $bundle, $entityName, ClassMetadata $metadata)
 {
     $className = sprintf("%sAdminType", $entityName);
     $dirPath = sprintf("%s/Form", $bundle->getPath());
     $classPath = sprintf("%s/%s.php", $dirPath, str_replace('\\', '/', $className));
     if (file_exists($classPath)) {
         throw new \RuntimeException(sprintf('Unable to generate the %s class as it already exists under the %s file', $className, $classPath));
     }
     $this->setSkeletonDirs(array($this->skeletonDir));
     $this->renderFile('/Form/EntityAdminType.php', $classPath, array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle, 'entity_class' => $entityName, 'fields' => $this->getFieldsFromMetadata($metadata)));
 }
 public function getNamespace()
 {
     return parent::getNamespace();
     // TODO: Change the autogenerated stub
 }
 /**
  * Transform classname to a path $foundBundle substract it to get the destination
  *
  * @param Bundle $bundle
  * @return string
  */
 protected function findBasePathForBundle($bundle)
 {
     $path = str_replace('\\', '/', $bundle->getNamespace());
     $search = str_replace('\\', '/', $bundle->getPath());
     $destination = str_replace('/' . $path, '', $search, $c);
     if ($c != 1) {
         throw new \RuntimeException(sprintf('Can\'t find base path for bundle (path: "%s", destination: "%s").', $path, $destination));
     }
     return $destination;
 }
Ejemplo n.º 13
0
 /**
  * Transform classname to a path $foundBundle substract it to get the destination
  *
  * @param Bundle $bundle
  * @return string
  */
 protected function findBasePathForBundle($bundle)
 {
     $path = str_replace('\\', '/', $bundle->getNamespace());
     $destination = str_replace('/' . $path, "", $bundle->getPath(), $c);
     if ($c != 1) {
         throw new \RuntimeException("Something went terribly wrong.");
     }
     return $destination;
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function getNamespace()
 {
     $namespace = parent::getNamespace();
     return substr($namespace, 0, strrpos($namespace, '\\'));
 }
Ejemplo n.º 15
0
 private function getConfiguration(Bundle $bundle)
 {
     if (isset($this->cacheConfigs[$bundle->getName()])) {
         return $this->cacheConfigs[$bundle->getName()];
     }
     $driverName = $this->connection->getDriver()->getName();
     $migrationsDir = "{$bundle->getPath()}/Migrations/{$driverName}";
     $migrationsName = "{$bundle->getName()} migration";
     $migrationsNamespace = "{$bundle->getNamespace()}\\Migrations\\{$driverName}";
     $migrationsTableName = 'doctrine_' . strtolower($bundle->getName()) . '_versions';
     $config = new Configuration($this->connection);
     $config->setName($migrationsName);
     $config->setMigrationsDirectory($migrationsDir);
     $config->setMigrationsNamespace($migrationsNamespace);
     $config->setMigrationsTableName($migrationsTableName);
     if (is_dir($migrationsDir)) {
         $config->registerMigrationsFromDirectory($migrationsDir);
     }
     $this->cacheConfigs[$bundle->getName()] = $config;
     return $config;
 }