當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。