Inheritance: extends Symfony\Component\DependencyInjection\ContainerAware, implements Symfony\Component\HttpKernel\Bundle\BundleInterface
Example #1
0
 /**
  * Add
  * 
  * Add a FrameworkBundle
  * to the collection
  * 
  * @param FrameworkBundle $bundle - the FrameworkBundle to add
  * 
  * @return BundleCollection - the current instance
  */
 public function add(Bundle $bundle)
 {
     if (!$this->has($bundle->getName())) {
         $this->bundles[] = $bundle;
     }
     return $this;
 }
 /**
  * @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>');
 }
 /**
  * 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));
 }
Example #4
0
 /**
  * Register an installer service
  *
  * @param BaseBundle $bundleInfos
  * @param string $type Type (install, update or uninstall)
  * @param string $class Class (Install, Update or Uninstall)
  */
 protected function registerInstallerService(BaseBundle $bundleInfos, $type, $class)
 {
     $serviceId = strtolower($bundleInfos->getName()) . '.installer.' . $type;
     $fullyQualifiedClass = $bundleInfos->getNamespace() . '\\Service\\Install\\' . $class;
     $serviceOptions = array('calls' => array(array('setContainer' => array('@service_container'))), 'tags' => array(array('name' => 'bundle.' . $type)));
     $this->registerService($bundleInfos->getName(), $serviceId, $fullyQualifiedClass, $serviceOptions);
 }
Example #5
0
 public static function addBundle(Bundle $bundle)
 {
     $extension = $bundle->getContainerExtension();
     if ($extension) {
         self::$extensions[] = $extension;
     }
     self::$bundlePaths[] = $bundle->getPath();
 }
 /**
  * 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;
 }
 /**
  * @param Bundle $bundle
  * @return ClassMetadata[]
  */
 protected function getBundleMetadata(Bundle $bundle)
 {
     $bundleMetadata = [];
     $metadata = $this->em->getMetadataFactory()->getAllMetadata();
     /** @var ClassMetadata $meta */
     foreach ($metadata as $meta) {
         if (strpos($meta->getName(), $bundle->getNamespace()) !== false) {
             $bundleMetadata[] = $meta;
         }
     }
     return $bundleMetadata;
 }
 /**
  * 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);
         }
     }
 }
Example #9
0
 /**
  * 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;
 }
 private function getBundleTables(Bundle $bundle, array $metadata)
 {
     $bundleTables = array('tables' => array(), 'joinTables' => array());
     foreach ($metadata as $entityMetadata) {
         if (0 === strpos($entityMetadata->name, $bundle->getNamespace())) {
             $bundleTables[] = $entityMetadata->getTableName();
             foreach ($entityMetadata->associationMappings as $association) {
                 if (isset($association['joinTable']['name'])) {
                     $bundleTables[] = $association['joinTable']['name'];
                 }
             }
         }
     }
     return $bundleTables;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new DataProviderPass());
     $container->addCompilerPass(new FilterPass());
     $container->addCompilerPass(new DoctrineQueryExtensionPass());
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new AddAccessorCompilerPass());
     $container->addCompilerPass(new AddStrategyCompilerPass());
     $container->addCompilerPass(new AddStepCompilerPass());
 }
Example #13
0
 /**
  * @param ContainerBuilder $container
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new ThemeRepositoryPass());
     $container->addCompilerPass(new ThemeAwareSourcesPass());
     $container->addCompilerPass(new ThemeAwareLoaderDecoratorPass());
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new LoadersCompilerPass());
     // Disable create cache directories for now; it's not needed anyway (structure is being created on the run).
     //            ->addCompilerPass(new CreateCacheDirectoriesCompilerPass(), PassConfig::TYPE_AFTER_REMOVING);
 }
Example #15
0
 /**
  * Builds the bundle.
  *
  * It is only ever called once when the cache is empty.
  *
  * This method can be overridden to register compilation passes,
  * other extensions, ...
  *
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new ThemeCompilerPass());
     $container->addCompilerPass(new TemplateResourcesPass());
     $container->addCompilerPass(new AddResolversPass());
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $passConfig = $container->getCompilerPassConfig();
     $passConfig->addPass(new AddAfterInvocationProvidersPass());
     $passConfig->addPass(new SecureMethodInvocationsPass($container->getParameter('kernel.cache_dir')), PassConfig::TYPE_BEFORE_REMOVING);
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new AutocompleteCompilerPass());
     $container->addCompilerPass(new FormCompilerPass());
     $container->addCompilerPass(new FormGuesserCompilerPass());
 }
 /**
  * @inheritdoc
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     // add module pass
     $container->addCompilerPass(new ModuleCompilerPass());
     $container->addCompilerPass(new ComponentCompilerPass());
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     /** @var $extension DependencyInjection\PayumExtension */
     $extension = $container->getExtension('payum');
     $extension->addPaymentFactory(new NganluongPaymentFactory());
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     /** @var \Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension $extension */
     $extension = $container->getExtension('security');
     $extension->addSecurityListenerFactory(new SamlFactory());
 }
 /**
  * @param ContainerBuilder $container
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new TwigGlobalsCompilerPass());
     $container->addCompilerPass(new RoleCompilerPass());
     $container->addCompilerPass(new RoleUsageCompilerPass());
 }
Example #22
0
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new RoutingResolverPass());
     $container->addCompilerPass(new ProfilerPass());
     // must be registered before removing private services as some might be listeners/subscribers
     // but as late as possible to get resolved parameters
     $container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
     $container->addCompilerPass(new TemplatingPass());
     $container->addCompilerPass(new AddConstraintValidatorsPass(), PassConfig::TYPE_BEFORE_REMOVING);
     $container->addCompilerPass(new AddValidatorInitializersPass());
     $container->addCompilerPass(new AddConsoleCommandPass());
     $container->addCompilerPass(new FormPass());
     $container->addCompilerPass(new TranslatorPass());
     $container->addCompilerPass(new LoggingTranslatorPass());
     $container->addCompilerPass(new AddCacheWarmerPass());
     $container->addCompilerPass(new AddCacheClearerPass());
     $container->addCompilerPass(new AddExpressionLanguageProvidersPass());
     $container->addCompilerPass(new TranslationExtractorPass());
     $container->addCompilerPass(new TranslationDumperPass());
     $container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
     $container->addCompilerPass(new SerializerPass());
     $container->addCompilerPass(new PropertyInfoPass());
     $container->addCompilerPass(new ControllerArgumentValueResolverPass());
     $container->addCompilerPass(new CachePoolPass());
     $container->addCompilerPass(new ValidateWorkflowsPass());
     $container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING);
     if ($container->getParameter('kernel.debug')) {
         $container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
         $container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
         $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
         $container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
         $container->addCompilerPass(new ConfigCachePass());
     }
 }
Example #23
0
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     // we need to add the request scope as early as possible so that
     // the compilation can find scope widening issues
     $container->addScope(new Scope('request'));
     $container->addCompilerPass(new RoutingResolverPass());
     $container->addCompilerPass(new ProfilerPass());
     // must be registered before removing private services as some might be listeners/subscribers
     // but as late as possible to get resolved parameters
     $container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
     $container->addCompilerPass(new TemplatingPass());
     $container->addCompilerPass(new AddConstraintValidatorsPass());
     $container->addCompilerPass(new AddValidatorInitializersPass());
     $container->addCompilerPass(new AddConsoleCommandPass());
     $container->addCompilerPass(new FormPass());
     $container->addCompilerPass(new TranslatorPass());
     $container->addCompilerPass(new AddCacheWarmerPass());
     $container->addCompilerPass(new AddCacheClearerPass());
     $container->addCompilerPass(new TranslationExtractorPass());
     $container->addCompilerPass(new TranslationDumperPass());
     $container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
     $container->addCompilerPass(new SerializerPass());
     if ($container->getParameter('kernel.debug')) {
         $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
         $container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
     }
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new ResourceProviderPass());
     $container->addCompilerPass(new FormResolverPass());
     $container->addCompilerPass(new FormDataTransformerPass());
 }
Example #25
0
 public function build(ContainerBuilder $container)
 {
     // register the extension(s) found in DependencyInjection/ directory
     parent::build($container);
     $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/Resources/config'));
     $loader->load('services.yml');
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new BlockProviderCompilerPass());
     $container->addCompilerPass(new RendererCompilerPass());
     $container->addCompilerPass(new MailerServiceCompilerPass());
 }
 /**
  * {@inheritDoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new TypesPass());
     $container->addCompilerPass(new DeleteIntegrationProvidersPass());
     $container->addCompilerPass(new SettingsPass());
 }
Example #28
0
 /**
  * {@inheritdoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     $container->addCompilerPass(new RegisterDriversPass());
     $container->addCompilerPass(new RegisterFiltersPass());
     $container->addCompilerPass(new RegisterFieldTypesPass());
 }
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     /** @var SecurityExtension $extension */
     $extension = $container->getExtension('security');
     $extension->addSecurityListenerFactory(new SspFactory());
 }
 /**
  * {@inheritDoc}
  */
 public function build(ContainerBuilder $container)
 {
     parent::build($container);
     /** @var $extension \Payum\Bundle\PayumBundle\DependencyInjection\PayumExtension */
     $extension = $container->getExtension('payum');
     $extension->addGatewayFactory(new RedsysGatewayFactory());
 }