当前位置: 首页>>代码示例>>PHP>>正文


PHP Bundle::getPath方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Bundle\Bundle::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::getPath方法的具体用法?PHP Bundle::getPath怎么用?PHP Bundle::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Bundle\Bundle的用法示例。


在下文中一共展示了Bundle::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateBehatTests

 /**
  * @param Bundle          $bundle
  * @param OutputInterface $output
  * @param array           $parameters
  */
 public function generateBehatTests(Bundle $bundle, OutputInterface $output, array $parameters)
 {
     $dirPath = sprintf("%s/Features", $bundle->getPath());
     $skeletonDir = sprintf("%s/Features", $this->fullSkeletonDir);
     // First copy all the content
     $this->filesystem->mirror($this->fullSkeletonDir, $bundle->getPath());
     // Now render the Context files to replace the namespace etc.
     if ($handle = opendir($skeletonDir . "/Context")) {
         while (false !== ($entry = readdir($handle))) {
             // Check to make sure we skip hidden folders
             // And we render the files ending in .php
             if (substr($entry, 0, 1) != '.' && substr($entry, -strlen(".php")) === ".php") {
                 $this->renderFile("/Features/Context/" . $entry, $dirPath . "/Context/" . $entry, $parameters);
             }
         }
         closedir($handle);
     }
     $featureContext = $dirPath . "/Context/FeatureContext.php";
     if ($this->filesystem->exists($featureContext)) {
         $contents = file_get_contents($featureContext);
         $contents = str_replace('-adminpwd-', $this->container->getParameter('kunstmaan_admin.admin_password'), $contents);
         file_put_contents($featureContext, $contents);
     }
     $output->writeln('Generating Behat Tests : <info>OK</info>');
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:30,代码来源:AdminTestsGenerator.php

示例2: loadFixtures

 /**
  * @param Bundle      $bundle
  * @param string[]    $filters
  * @param string      $connection
  * @param string|null $locale
  */
 public function loadFixtures(Bundle $bundle, array $filters, $connection, $locale = null)
 {
     if (false === is_dir(sprintf('%s/Resources/fixtures/orm', $bundle->getPath()))) {
         return;
     }
     $files = (new Finder())->files()->in(sprintf('%s/Resources/fixtures/orm', $bundle->getPath()))->sortByName();
     foreach ($filters as $filter) {
         $files->name($filter);
     }
     foreach ($files as $file) {
         $event = new Event($bundle, $file);
         $this->dispatcher->dispatch(Events::PRE_LOAD, $event);
         $event->setObjects($this->getFixtures($connection, $locale)->loadFiles($file));
         $this->dispatcher->dispatch(Events::POST_LOAD, $event);
     }
 }
开发者ID:Devolicious,项目名称:rad-fixtures-load,代码行数:22,代码来源:Loader.php

示例3: generateEntityClass

 /**
  * Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance
  *
  * @param ClassMetadataInfo     $metadata
  * @param Bundle                $bundle
  * @param string                $entity
  * @param array                 $fields
  * @param bool                  $hasI18n
  * @param bool                  $isTimestampable
  * @param bool                  $isSluggable
  *
  * @return string $code
  */
 public function generateEntityClass(ClassMetadataInfo $metadata, $bundle = null, $entity = null, $fields = array(), $hasI18n = false, $isTimestampable = false, $isSluggable = false)
 {
     $target = sprintf('%s/Entity/%s.php', $bundle->getPath(), $entity);
     $namespace = $this->generateEntityNamespace($metadata);
     $code = str_replace('<spaces>', $this->spaces, $this->generateEntityBody($metadata));
     $bundleName = explode('\\Entity', $metadata->name);
     $routePrefix = strtolower(str_replace('\\', '_', str_replace('Bundle', '', $bundleName[0]))) . '_backend';
     $routeName = $routePrefix . strtolower(str_replace('\\', '_', $bundleName[1]));
     // Track all the translation fields and check if it contains the fieldName 'name'
     // and check if the name field is i18n
     $containNameField = false;
     $nameIsI18n = false;
     foreach ($fields as $field) {
         if ($field['fieldName'] == 'name') {
             $containNameField = true;
             if (substr(strtolower($field['i18n']), 0, 1) == 'y') {
                 $nameIsI18n = true;
             }
         }
     }
     if ($containNameField) {
         $functionName = '$this->getName()';
     } else {
         $functionName = '$this->getEntityName()';
     }
     $this->renderFile('entity/Entity.php.twig', $target, array('namespace' => $namespace, 'route' => $routeName, 'entity' => $entity, 'entity_var' => $this->getEntityVar($entity), 'code' => $code, 'name_function' => $functionName, 'is_timestampable' => $isTimestampable, 'is_sluggable' => $isSluggable, 'sluggable_name' => !$nameIsI18n && $isSluggable, 'has_i18n' => $hasI18n));
 }
开发者ID:pmdc,项目名称:UnifikSystemBundle,代码行数:40,代码来源:EntityGenerator.php

示例4: addBundle

 public static function addBundle(Bundle $bundle)
 {
     $extension = $bundle->getContainerExtension();
     if ($extension) {
         self::$extensions[] = $extension;
     }
     self::$bundlePaths[] = $bundle->getPath();
 }
开发者ID:bjanish,项目名称:symfonize-zf,代码行数:8,代码来源:Loader.php

示例5: 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;
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:19,代码来源:AbstractCommand.php

示例6: 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);
         }
     }
 }
开发者ID:tweedegolf,项目名称:generatorbundle,代码行数:17,代码来源:SymfonyGeneratorRegistry.php

示例7: deleteUpperMigrationClasses

 /**
  * Deletes bundle migration classes for a given driver which are above a
  * reference version.
  *
  * @param \Symfony\Component\HttpKernel\Bundle\Bundle   $bundle
  * @param string                                        $driverName
  * @param string                                        $referenceVersion
  * @return array The migration files that were deleted
  */
 public function deleteUpperMigrationClasses(Bundle $bundle, $driverName, $referenceVersion)
 {
     $migrations = new \DirectoryIterator("{$bundle->getPath()}/Migrations/{$driverName}");
     $deletedVersions = array();
     foreach ($migrations as $migration) {
         if (preg_match('#Version(\\d+)\\.php#', $migration->getFilename(), $matches)) {
             if ($matches[1] > $referenceVersion) {
                 $this->fileSystem->remove(array($migration->getPathname()));
                 $deletedVersions[] = $migration->getFilename();
             }
         }
     }
     return $deletedVersions;
 }
开发者ID:Netmisa,项目名称:MigrationBundle,代码行数:23,代码来源:Writer.php

示例8: generateEntityClass

 /**
  * Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance
  *
  * @param ClassMetadataInfo     $metadata
  * @param Bundle                $bundle
  * @param string                $entity
  * @param array                 $fields
  * @param bool                  $isSluggable
  *
  * @return string $code
  */
 public function generateEntityClass(ClassMetadataInfo $metadata, $bundle = null, $entity = null, $fields = array(), $isSluggable = false)
 {
     $target = sprintf('%s/Entity/%s.php', $bundle->getPath(), $entity);
     $namespace = $this->generateEntityNamespace($metadata);
     $code = str_replace('<spaces>', $this->spaces, $this->generateEntityBody($metadata));
     $bundleName = explode('\\Entity', $metadata->name);
     $routePrefix = strtolower(str_replace('\\', '_', str_replace('Bundle', '', $bundleName[0]))) . '_backend';
     $routeName = $routePrefix . strtolower(str_replace('\\', '_', $bundleName[1]));
     // Track all the translation fields and check if it contains the fieldName 'name'
     // or a slug
     $containNameField = false;
     foreach ($fields as $field) {
         if ($field['fieldName'] == 'name' && substr(strtolower($field['i18n']), 0, 1) == 'y') {
             $containNameField = true;
         }
     }
     $this->renderFile('entity/EntityTranslation.php.twig', $target, array('namespace' => $namespace, 'route' => $routeName, 'entity' => $entity, 'code' => $code, 'is_sluggable' => $isSluggable, 'sluggable_name' => $isSluggable && $containNameField));
 }
开发者ID:pmdc,项目名称:UnifikSystemBundle,代码行数:29,代码来源:EntityTranslationGenerator.php

示例9: 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;
 }
开发者ID:Wizkunde,项目名称:DoctrineMongoDBBundle,代码行数:16,代码来源:DoctrineODMCommand.php

示例10: updateRouting

 /**
  * @param DialogHelper    $dialog      The dialog helper
  * @param InputInterface  $input       The command input
  * @param OutputInterface $output      The command output
  * @param Bundle          $bundle      The bundle
  * @param string          $entityClass The classname of the entity
  *
  * @return void
  */
 protected function updateRouting(DialogHelper $dialog, InputInterface $input, OutputInterface $output, Bundle $bundle, $entityClass)
 {
     $auto = true;
     $multilang = false;
     if ($input->isInteractive()) {
         $multilang = $dialog->askConfirmation($output, $dialog->getQuestion('Is it a multilanguage site', 'yes', '?'), true);
         $auto = $dialog->askConfirmation($output, $dialog->getQuestion('Do you want to update the routing automatically', 'yes', '?'), true);
     }
     $prefix = $multilang ? '/{_locale}' : '';
     $code = sprintf("%s:\n", strtolower($bundle->getName()) . '_' . strtolower($entityClass) . '_admin_list');
     $code .= sprintf("    resource: @%s/Controller/%sAdminListController.php\n", $bundle->getName(), $entityClass);
     $code .= "    type:     annotation\n";
     $code .= sprintf("    prefix:   %s/admin/%s/\n", $prefix, strtolower($entityClass));
     if ($multilang) {
         $code .= "    requirements:\n";
         $code .= "         _locale: %requiredlocales%\n";
     }
     if ($auto) {
         $file = $bundle->getPath() . '/Resources/config/routing.yml';
         $content = '';
         if (file_exists($file)) {
             $content = file_get_contents($file);
         } elseif (!is_dir($dir = dirname($file))) {
             mkdir($dir, 0777, true);
         }
         $content .= "\n";
         $content .= $code;
         if (false === file_put_contents($file, $content)) {
             $output->writeln($dialog->getHelperSet()->get('formatter')->formatBlock("Failed adding the content automatically", 'error'));
         } else {
             return;
         }
     }
     $output->writeln('Add the following to your routing.yml');
     $output->writeln('/*******************************/');
     $output->write($code);
     $output->writeln('/*******************************/');
 }
开发者ID:tentwofour,项目名称:KunstmaanGeneratorBundle,代码行数:47,代码来源:GenerateAdminListCommand.php

示例11: getPackageFromBundle

 /**
  * @param Bundle $bundle
  * @param string $namespace
  *
  * @return string
  */
 protected function getPackageFromBundle(Bundle $bundle, $namespace)
 {
     //find relative path from namespace to bundle->getNamespace()
     $baseNamespace = (new \ReflectionClass($bundle))->getNamespaceName();
     if (0 === strpos($namespace, $baseNamespace)) {
         //base namespace fits
         //eg.
         //  Base: Jarves/JarvesBundle => Jarves
         //  Model namespace: Jarves\Model
         //  strpos(Jarves\Model, Jarves) === 0
         // $namespaceDiff = Model
         $namespaceDiff = substr($namespace, strlen($baseNamespace) + 1);
         $bundlePath = realpath($bundle->getPath()) . '/' . str_replace('\\', '/', $namespaceDiff);
         $appPath = realpath($this->getApplication()->getKernel()->getRootDir() . '/..');
         $path = static::getRelativePath($bundlePath, $appPath);
         return str_replace('/', '.', $path);
     }
     //does not match or its a absolute path, so return it without suffix
     if ('\\' === $namespace[0]) {
         $namespace = substr($namespace, 1);
     }
     return str_replace('\\', '.', $namespace);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:29,代码来源:AbstractCommand.php

示例12: processPlugin

 /**
  * Process plugin
  *
  * @param Bundle $plugin Plugin
  *
  * @return array Plugin configuration
  */
 protected function processPlugin(Bundle $plugin)
 {
     $resourcePath = $plugin->getPath() . '/Resources/config/external.yml';
     return file_exists($resourcePath) ? Yaml::parse(file_get_contents($resourcePath)) : [];
 }
开发者ID:xphere,项目名称:elcodi,代码行数:12,代码来源:ElcodiPluginExtension.php

示例13: getPath

 public function getPath()
 {
     return parent::getPath() . '/bundle';
 }
开发者ID:noelg,项目名称:symfony-demo,代码行数:4,代码来源:TestBundle.php

示例14: 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;
 }
开发者ID:claroline,项目名称:distribution,代码行数:21,代码来源:Migrator.php

示例15: getDefaultDirectoriesForBundle

 /**
  * @param Bundle $bundle bundle
  *
  * @return array
  */
 public function getDefaultDirectoriesForBundle(Bundle $bundle)
 {
     return array(sprintf('%s/Tests/Units', $bundle->getPath()), sprintf('%s/Tests/Controller', $bundle->getPath()));
 }
开发者ID:aliel,项目名称:AtoumBundle,代码行数:9,代码来源:AtoumCommand.php


注:本文中的Symfony\Component\HttpKernel\Bundle\Bundle::getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。