Get bundle index

@param string $bundle
@param int    $projectId

@return array
323943
public function getKeyIndex($bundle, $projectId = null)
    {
        $url = sprintf($this->url_plan['get_key_index'], $projectId ?: $this->project_id, $bundle);

        return $this->callService($url);
    }
1268912
private function getBundle($bundleComposer)
    {
        if (!file_exists($bundleComposer)) {
            return false;
        }

        $bundleComposerData = file_get_contents($bundleComposer);

        $normalizer = new GetSetMethodNormalizer();
        $normalizer->setIgnoredAttributes(array(
            'require',
            'keywords',
        ));
        $encoder = new JsonEncoder();
        $serializer = new Serializer(array($normalizer), array($encoder));
        $bundle = $serializer->deserialize($bundleComposerData,'CampaignChain\CoreBundle\Entity\Bundle','json');

        // Set the version of the installed bundle.
        $version = $this->packageService->getVersion($bundle->getName());

        /*
         * If version does not exist, this means two things:
         *
         * 1) Either, it is a package in require-dev of composer.json, but
         * CampaignChain is not in dev mode. Then we don't add this package.
         *
         * 2) Or it is a bundle in Symfony's src/ directory. Then we want to
         * add it.
         */
        if(!$version){
            // Check if bundle is in src/ dir.
            $bundlePath = str_replace($this->rootDir.DIRECTORY_SEPARATOR, '', $bundleComposer);
            if(strpos($bundlePath, 'src'.DIRECTORY_SEPARATOR) !== 0){
                // Not in src/ dir, so don't add this bundle.
                return false;
            } else {
                $version = 'dev-master';
            }
        }

        $bundle->setVersion($version);

        // Set relative path of bundle.
        $bundle->setPath(
        // Remove the root directory to get the relative path
            str_replace($this->rootDir.DIRECTORY_SEPARATOR, '',
                // Remove the composer file from the path
                str_replace(DIRECTORY_SEPARATOR.'composer.json', '', $bundleComposer)
            )
        );

        return $bundle;
    }
1240240
public function getBundles($extension = null)
    {
        if ($extension === null) {
            return $this->bundles;
        }
        elseif (isset($this->bundles[$extension])) {
            return $this->bundles[$extension];
        }
        else {
            return null;
        }
    }
822827
public function bitbucket($projectId)
    {
        $project = $this->fetchProject($projectId, 'bitbucket');
    
        // Support both old services and new webhooks
        if ($payload = $this->getParam('payload')) {
            return $this->bitbucketService(json_decode($payload, true), $project);
        }

        $payload = json_decode(file_get_contents("php://input"), true);

        if (empty($payload['push']['changes'])) {
            // Invalid event from bitbucket
            return [
                'status' => 'failed',
                'commits' => []
            ];
        }

        return $this->bitbucketWebhook($payload, $project);
    }
596044
def get_bundle_by_id(self, bundle_id):
        # type: (int) -> Union[Bundle, Framework]
        
        if bundle_id == 0:
            # "System bundle"
            return self

        with self.__bundles_lock:
            if bundle_id not in self.__bundles:
                raise BundleException("Invalid bundle ID {0}".format(bundle_id))

            return self.__bundles[bundle_id]
1062492
protected function getGenerator(BundleInterface $bundle = null)
    {
        $dirs[] = $this->getContainer()->get('file_locator')->locate('@VictoireWidgetBundle/Resources/skeleton/');
        $dirs[] = $this->getContainer()->get('file_locator')->locate('@VictoireWidgetBundle/Resources/');

        $generator = $this->createWidgetGenerator();

        $this->skeletonDirs = array_merge($this->getSkeletonDirs(), $dirs);
        $generator->setSkeletonDirs($this->skeletonDirs);
        $this->setGenerator($generator);

        return $generator;
    }
344283
public function getOwnBundles()
    {
        $bundles = array();
        $counter = 1;

        $dir = dirname($this->container->getParameter('kernel.root_dir') . '/') . '/src/';
        $files = scandir($dir);
        foreach ($files as $file) {
            if (is_dir($dir . $file) && !in_array($file, array('.', '..'))) {
                $bundleFiles = scandir($dir . $file);
                foreach ($bundleFiles as $bundleFile) {
                    if (is_dir($dir . $file . '/' . $bundleFile) && !in_array($bundleFile, array('.', '..'))) {
                        $bundles[$counter++] = array(
                            'name' => $bundleFile,
                            'namespace' => $file,
                            'dir' => $dir . $file . '/' . $bundleFile,
                        );
                    }
                }
            }
        }

        return $bundles;
    }
260158
private function findTemplatesInThemes(BundleInterface $bundle, $theme)
    {
        $templates = $this->findTemplatesInFolder($bundle->getPath().'/Resources/themes/'.$theme);
        $name = $bundle->getName();

        foreach ($templates as $i => $template) {
            $templates[$i] = $template->set('bundle', $name);
        }

        return $templates;
    }
511294
public function findClasses($bundles, $directory = '', $type = '')
    {
        $finder = Finder::create()->files()->name('*.php')->sortByName()->ignoreUnreadableDirs();
        $found  = false;

        foreach ($bundles as $bundle) {
            $path = rtrim($bundle->getPath(), DIRECTORY_SEPARATOR);

            if (true === empty($directory)) {
                $found = true;
                $finder->in($path);
                continue;
            }

            if (false === is_array($directory)) {
                $directory = [$directory];
            }

            foreach ($directory as $dir) {
                $pathname = sprintf('%s%s%s', $path, DIRECTORY_SEPARATOR, trim($dir, DIRECTORY_SEPARATOR));
                if (true === is_dir($pathname)) {
                    $found = true;
                    $finder->in($pathname);
                }
            }
        }

        if (false === $found) {
            return [];
        }

        $files = [];
        foreach ($finder as $file) {
            $files[] = $file->getPathname();
        }

        $classes = [];
        foreach ($files as $file) {
            foreach ($bundles as $bundle) {
                if (null !== $class = $this->getClassFromFileAndBundle($file, $bundle)) {
                    $classes[] = $class;
                    continue;
                }
            }
        }

        $classes = array_filter($classes, function ($e) {
            return class_exists($e);
        });

        if (false === empty($type)) {
            if (false === (class_exists($type) || interface_exists($type))) {
                throw new \InvalidArgumentException(sprintf('Class or interface "%s" unknown', $type));
            }
            $classes = array_filter($classes, function ($e) use ($type) {
                return is_subclass_of($e, $type);
            });
        }

        return $classes;
    }
660749
protected function getRequiredBundleGenerators($bundle)
    {
        return [
            $this->createZedBundleCodeGenerator($bundle),
            $this->createYvesBundleCodeGenerator($bundle),
            $this->createClientBundleCodeGenerator($bundle),
            $this->createServiceBundleCodeGenerator($bundle),
            $this->createSharedBundleCodeGenerator($bundle),
        ];
    }
994222
public function getKeysByBundle($bundle)
    {
        $em = $this->getEntityManager();

        $queryBuilder = $em->createQueryBuilder();
        $queryBuilder->select('t')
            ->from('TranslationsApiBundle:Translation', 't')
            ->where('t.bundle = :bundle')
            ->setParameter('bundle', $bundle)
        ;

        return $queryBuilder->getQuery()->getResult();
    }
1198183
public static function getLocales(string $bundle) :array {

		// declare an array to hold the list
		$locales = array();
		// set the locales path
		$locales_path = "../Private/Bundles/{$bundle}/Locales/";
		// if the directory exists
		if(file_exists($locales_path) && is_dir($locales_path)) {
			// for each file in the directory
			foreach(scandir($locales_path) as $locales_file) {
				// if the file is a normal one
				if(substr($locales_file,0,1) != '.' ) {
					// push it into the array of locales
					$locales[] = $locales_path . $locales_file ;
				}
			}
		}
		// return all found locales
		return($locales);
		
	}
539701
public function getProjectEvents($projectId = null)
    {
        $projectId = $projectId ?: $this->defaultProjectId;

        return $this->curl->get("projects/{$projectId}/events");
    }
657053
protected function getStatus($projectId)
    {
        $branch = $this->getParam('branch', 'master');
        try {
            $project = $this->projectStore->getById($projectId);
            $status = 'passing';

            if (!$project->getAllowPublicStatus()) {
                return null;
            }

            if (isset($project) && $project instanceof Project) {
                $build = $project->getLatestBuild($branch, array(2,3));

                if (isset($build) && $build instanceof Build && $build->getStatus() != 2) {
                    $status = 'failed';
                }
            }
        } catch (\Exception $e) {
            $status = 'error';
        }

        return $status;
    }
285063
private function findGeneratorYamlInBundle(BundleInterface $bundle)
    {
        $yamls =  array();

        if (!file_exists($bundle->getPath().'/Resources/config')) {
            return $yamls;
        }

        $finder = new Finder();
        $finder->files()
               ->name('generator.yml')
               ->name('*-generator.yml')
               ->in($bundle->getPath().'/Resources/config');

        foreach ($finder as $file) {
            $yamls[$file->getRealPath()] = $file->getRealPath();
        }

        return $yamls;
    }
1355372
public static function option($bundle, $option, $default = null)
		{
			$bundle = static::get($bundle);

			if (is_null($bundle)) {
				return value($default);
			}

			return arrayGet($bundle, $option, $default);
		}
90562
public static function registerBundle(string $bundleId, \stdClass $bundle)
    {
        $bundle->bundleId = $bundleId;
        self::$runtimeBundles[$bundleId] = $bundle;
    }