本文整理汇总了PHP中Symfony\Component\HttpKernel\KernelInterface::getBundles方法的典型用法代码示例。如果您正苦于以下问题:PHP KernelInterface::getBundles方法的具体用法?PHP KernelInterface::getBundles怎么用?PHP KernelInterface::getBundles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\KernelInterface
的用法示例。
在下文中一共展示了KernelInterface::getBundles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLocations
/**
* Gets translation files location.
*
* @return array
*/
private function getLocations()
{
$locations = array();
if (class_exists('Symfony\\Component\\Validator\\Validator')) {
$r = new \ReflectionClass('Symfony\\Component\\Validator\\Validator');
$locations[] = dirname($r->getFilename()) . '/Resources/translations';
}
if (class_exists('Symfony\\Component\\Form\\Form')) {
$r = new \ReflectionClass('Symfony\\Component\\Form\\Form');
$locations[] = dirname($r->getFilename()) . '/Resources/translations';
}
if (class_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException')) {
$r = new \ReflectionClass('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException');
if (file_exists($dir = dirname($r->getFilename()) . '/../../Resources/translations')) {
$locations[] = $dir;
} else {
// Symfony 2.4 and above
$locations[] = dirname($r->getFilename()) . '/../Resources/translations';
}
}
$overridePath = $this->kernel->getRootDir() . '/Resources/%s/translations';
foreach ($this->kernel->getBundles() as $bundle => $class) {
$reflection = new \ReflectionClass($class);
if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) {
$locations[] = $dir;
}
if (is_dir($dir = sprintf($overridePath, $bundle))) {
$locations[] = $dir;
}
}
if (is_dir($dir = $this->kernel->getRootDir() . '/Resources/translations')) {
$locations[] = $dir;
}
return $locations;
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$noInitialize = $input->getOption('no-initialize');
$append = $input->getOption('append');
if ($input->isInteractive() && !$append) {
$dialog = $this->getHelperSet()->get('dialog');
$confirmed = $dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false);
if (!$confirmed) {
return 0;
}
}
$paths = $input->getOption('fixtures');
$candidatePaths = [];
if (!$paths) {
$paths = [];
foreach ($this->kernel->getBundles() as $bundle) {
$candidatePath = $bundle->getPath() . '/DataFixtures/Document';
$candidatePaths[] = $candidatePath;
if (file_exists($candidatePath)) {
$paths[] = $candidatePath;
}
}
}
if (empty($paths)) {
$output->writeln('<info>Could not find any candidate fixture paths.</info>');
if ($input->getOption('verbose')) {
$output->writeln(sprintf('Looked for: </comment>%s<comment>"</comment>', implode('"<comment>", "</comment>', $candidatePaths)));
}
return 0;
}
$fixtures = $this->loader->load($paths);
$this->executor->execute($fixtures, false === $append, false === $noInitialize, $output);
$output->writeln('');
$output->writeln(sprintf('<info>Done. Executed </info>%s</info><info> fixtures.</info>', count($fixtures)));
}
示例3: getConfigurations
/**
* @return array
*/
public function getConfigurations()
{
if ($this->configuration !== null) {
return $this->configuration;
}
$bundles = $this->kernel->getBundles();
$configuration = [];
foreach ($bundles as $bundle) {
try {
$class = get_class($bundle);
$classParts = explode('\\', $class);
$bundleName = array_pop($classParts);
$file = $this->kernel->locateResource(sprintf('@%s/Resources/config/search.yml', $bundleName));
} catch (\Exception $e) {
continue;
}
$data = $this->parseFile($file);
if (is_array($data)) {
foreach ($data as $class => $config) {
$configuration[$class] = $config;
}
}
}
$this->configuration = $configuration;
return $configuration;
}
示例4: collect
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array('app_name' => $this->name, 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, 'symfony_state' => 'unknown', 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, 'xdebug_enabled' => extension_loaded('xdebug'), 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI);
if (isset($this->kernel)) {
foreach ($this->kernel->getBundles() as $name => $bundle) {
$this->data['bundles'][$name] = $bundle->getPath();
}
$this->data['symfony_state'] = $this->determineSymfonyState();
}
}
示例5: getBundleForClass
/**
* Returns the Bundle instance in which the given class name is located.
*
* @param string $class A fully qualified controller class name
* @param Bundle $bundle A Bundle instance
* @throws \InvalidArgumentException
*/
protected function getBundleForClass($class)
{
$namespace = strtr(dirname(strtr($class, '\\', '/')), '/', '\\');
foreach ($this->kernel->getBundles() as $bundle) {
if (0 === strpos($namespace, $bundle->getNamespace())) {
return $bundle;
}
}
throw new \InvalidArgumentException(sprintf('The "%s" class does not belong to a registered bundle.', $class));
}
示例6: installAssets
/**
* {@inheritdoc}
*/
public function installAssets($targetDir, $symlinkMask)
{
// Create the bundles directory otherwise symlink will fail.
$targetDir = rtrim($targetDir, '/') . '/bundles/';
$this->filesystem->mkdir($targetDir);
$effectiveSymlinkMask = $symlinkMask;
foreach ($this->kernel->getBundles() as $bundle) {
$effectiveSymlinkMask = min($effectiveSymlinkMask, $this->installBundleAssets($bundle, $targetDir, $symlinkMask));
}
return $effectiveSymlinkMask;
}
示例7: process
public function process(ContainerBuilder $container)
{
if (!$container->has('ezpublish_legacy.legacy_bundles.extension_locator')) {
return;
}
$locator = $container->get('ezpublish_legacy.legacy_bundles.extension_locator');
$extensionNames = array();
foreach ($this->kernel->getBundles() as $bundle) {
$extensionNames += array_flip($locator->getExtensionNames($bundle));
}
$container->setParameter('ezpublish_legacy.legacy_bundles_extensions', array_keys($extensionNames));
}
示例8: getPossibleViewDirectories
/**
* Returns paths to directories that *might* contain Twig views.
*
* Please note, that it is not guaranteed that these directories exist.
*
* @return string[]
*/
protected function getPossibleViewDirectories()
{
$viewDirectories = array();
$globalResourceDirectory = $this->kernel->getRootDir() . '/Resources';
$viewDirectories[] = $globalResourceDirectory;
foreach ($this->kernel->getBundles() as $bundle) {
/* @var $bundle BundleInterface */
$viewDirectory = $bundle->getPath() . '/Resources/views';
$viewDirectories[] = $viewDirectory;
}
return $viewDirectories;
}
示例9: getBundles
/**
* {@inheritdoc}
*/
public function getBundles()
{
$bundles = $this->kernel->getBundles();
if (!empty($this->excludeBundleNames)) {
foreach ($bundles as $key => $bundle) {
if (in_array($bundle->getName(), $this->excludeBundleNames)) {
unset($bundles[$key]);
}
}
}
return $bundles;
}
示例10: getBundleForClass
/**
* Returns bundle for particular controller
*
* @param ReflectionClass $class
*
* @return \Symfony\Component\HttpKernel\Bundle\BundleInterface
*/
protected function getBundleForClass(ReflectionClass $reflectionClass)
{
$bundles = $this->kernel->getBundles();
do {
$namespace = $reflectionClass->getNamespaceName();
foreach ($bundles as $bundle) {
if (0 === strpos($namespace, $bundle->getNamespace())) {
return $bundle;
}
}
$reflectionClass = $reflectionClass->getParentClass();
} while ($reflectionClass);
}
示例11: formatModule
/**
* Get correct casing of the module which is based on the bundle.
*
* @param string $module
* @return string
*/
public function formatModule($module)
{
$module = strtolower($module);
if (isset($this->moduleCache[$module])) {
return $this->moduleCache[$module];
}
foreach ($this->kernel->getBundles() as $bundle) {
if ($module . "bundle" == strtolower($bundle->getName())) {
return $this->moduleCache[$module] = str_replace("Bundle", "", $bundle->getName());
}
}
throw new \RuntimeException("Couldnt find a matching bundle for the module {$module}");
}
示例12: getResources
/**
* {@inheritdoc}
*/
protected function getResources()
{
$resources = [];
foreach ($this->kernel->getBundles() as $bundle) {
foreach ($this->relativeFilePaths as $relativeFilePath) {
$path = $bundle->getPath() . DIRECTORY_SEPARATOR . $relativeFilePath;
if (file_exists($path)) {
$resources[] = $path;
}
}
}
return $resources;
}
示例13: getBundleName
protected function getBundleName($className)
{
$bundles = $this->kernel->getBundles();
foreach ($bundles as $bundle) {
$class = get_class($bundle);
$classParts = explode('\\', $class);
$bundleName = array_pop($classParts);
$bundlePath = implode('\\', $classParts);
if (strpos($className, $bundlePath) === 0) {
return $bundleName;
}
}
return null;
}
示例14: getBundles
/**
* @return Symfony\Component\HttpKernel\Bundle\BundleInterface[]
*/
public function getBundles()
{
$bundles = $this->kernel->getBundles();
if (true === empty($this->bundles)) {
return $bundles;
}
$return = [];
foreach ($bundles as $bundle) {
if (true === in_array($bundle->getName(), $this->bundles)) {
$return[] = $bundle;
}
}
return $return;
}
示例15: getResources
/**
* Returns an array of translation files for a given domain and a given locale.
*
* @param string $domainName A domain translation name.
* @param string $locale A locale.
* @return array An array of translation files.
*/
public function getResources($domainName, $locale)
{
$finder = new Finder();
$locations = array();
foreach ($this->kernel->getBundles() as $bundle) {
if (is_dir($bundle->getPath() . '/Resources/translations')) {
$locations[] = $bundle->getPath() . '/Resources/translations';
}
}
if (is_dir($this->kernel->getRootDir() . '/Resources/translations')) {
$locations[] = $this->kernel->getRootDir() . '/Resources/translations';
}
return $finder->files()->name($domainName . '.' . $locale . '.*')->followLinks()->in($locations);
}