本文整理汇总了PHP中Symfony\Component\HttpKernel\Bundle\Bundle::getNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::getNamespace方法的具体用法?PHP Bundle::getNamespace怎么用?PHP Bundle::getNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Bundle\Bundle
的用法示例。
在下文中一共展示了Bundle::getNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerInstallerService
/**
* 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);
}
示例2: generate
/**
* @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);
}
示例3: generate
/**
* @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);
}
}
示例4: getPackagePrefix
/**
* 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;
}
示例5: getBundleMetadata
/**
* @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;
}
示例6: writeMigrationClass
/**
* 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);
}
示例7: loadGeneratorsForBundle
/**
* 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);
}
}
}
示例8: getBundleTables
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;
}
示例9: generate
/**
* @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);
}
}
示例10: generateAdminType
/**
* @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)));
}
示例11: getNamespace
public function getNamespace()
{
return parent::getNamespace();
// TODO: Change the autogenerated stub
}
示例12: findBasePathForBundle
/**
* 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;
}
示例13: findBasePathForBundle
/**
* 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;
}
示例14: getNamespace
/**
* {@inheritdoc}
*/
public function getNamespace()
{
$namespace = parent::getNamespace();
return substr($namespace, 0, strrpos($namespace, '\\'));
}
示例15: getConfiguration
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;
}