本文整理汇总了PHP中Symfony\Component\HttpKernel\Bundle\Bundle类的典型用法代码示例。如果您正苦于以下问题:PHP Bundle类的具体用法?PHP Bundle怎么用?PHP Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* 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;
}
示例2: 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>');
}
示例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));
}
示例4: registerInstallerService
/**
* 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);
}
示例5: addBundle
public static function addBundle(Bundle $bundle)
{
$extension = $bundle->getContainerExtension();
if ($extension) {
self::$extensions[] = $extension;
}
self::$bundlePaths[] = $bundle->getPath();
}
示例6: 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;
}
示例7: getBundleMetadata
/**
* @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;
}
示例8: 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);
}
}
}
示例9: 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;
}
示例10: getBundleTables
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;
}
示例11: build
public function build(ContainerBuilder $container)
{
parent::build($container);
/** @var \Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension $extension */
$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new SamlFactory());
}
开发者ID:eefjevanderharst,项目名称:Stepup-SelfService,代码行数:7,代码来源:SurfnetStepupSelfServiceSelfServiceBundle.php
示例12: build
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new DataProviderPass());
$container->addCompilerPass(new FilterPass());
$container->addCompilerPass(new DoctrineQueryExtensionPass());
}
示例13: build
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new AddAccessorCompilerPass());
$container->addCompilerPass(new AddStrategyCompilerPass());
$container->addCompilerPass(new AddStepCompilerPass());
}
示例14: build
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new ThemeRepositoryPass());
$container->addCompilerPass(new ThemeAwareSourcesPass());
$container->addCompilerPass(new ThemeAwareLoaderDecoratorPass());
}
示例15: build
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);
}