Symfony\Component\HttpKernel\Bundle\Bundle::getPath PHP Method

getPath() public method

Gets the Bundle directory path.
public getPath ( ) : string
return string The Bundle absolute path
    public function getPath()
    {
        if (null === $this->path) {
            $reflected = new \ReflectionObject($this);
            $this->path = dirname($reflected->getFileName());
        }

        return $this->path;
    }

Usage Example

 /**
  * @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>');
 }
All Usage Examples Of Symfony\Component\HttpKernel\Bundle\Bundle::getPath