PHP ContainerBuilder Code Examples

This page contains top rated real world PHP examples of ContainerBuilder extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: listener.php Project: phpbb-es/Buttonmenu
0
 public function page_header_after($event)
 {
     $context = $this->phpbb_container->get('template_context');
     $rootref =& $context->get_root_ref();
     if (isset($this->config['menu_enabled']) && $this->config['menu_enabled']) {
         $sql = 'SELECT *
	FROM ' . $this->menu_colors;
         $result = $this->db->sql_query($sql);
         $row = $this->db->sql_fetchrow($result);
         if ($this->db->sql_affectedrows()) {
             $this->template->assign_vars(array('S_MENU_COLOR' => $row['color_name'], 'S_MENU_FONT_COLOR' => $row['color_text'], 'S_MENU_FONT_COLOR_HOVER' => $row['color_text_hover'], 'S_MENU_DECORATION' => $row['color_text_hover_decor'], 'S_MENU_WEIGHT' => $row['color_text_weight'], 'S_MENU_SEARCH' => $row['color_display_search'], 'S_MENU_TEXT_TRANSFORM' => $row['color_text_transform'], 'S_MENU_ALIGN' => $row['color_align']));
             $sql = 'SELECT *
		FROM ' . $this->menu_buttons . '
		WHERE button_display = 1
			AND parent_id = 0
		ORDER BY left_id';
             $result = $this->db->sql_query($sql);
             while ($row = $this->db->sql_fetchrow($result)) {
                 if ($row['button_only_registered'] && $this->user->data['user_id'] == ANONYMOUS || $row['button_only_guest'] && $this->user->data['user_id'] != ANONYMOUS) {
                     continue;
                 }
                 if (preg_match("/\\{(.*)\\}/", $row['button_url'])) {
                     $brackets = array("{", "}");
                     $var_name = strtoupper(str_replace($brackets, '', $row['button_url']));
                     $row['button_url'] = $rootref[$var_name];
                 }
                 if (preg_match("/\\{(.*)\\}/", $row['button_name'])) {
                     $brackets = array("{L_", "}");
                     $var_name = strtoupper(str_replace($brackets, '', $row['button_name']));
                     $row['button_name'] = $this->user->lang[$var_name];
                 }
                 $this->template->assign_block_vars('buttons', array('ID' => $row['button_id'], 'URL' => $row['button_url'], 'NAME' => $row['button_name'], 'EXTERNAL' => $row['button_external']));
                 $sub_sql = 'SELECT *
			FROM ' . $this->menu_buttons . '
			WHERE button_display = 1
				AND parent_id = ' . $row['button_id'] . '
			ORDER BY left_id';
                 $sub_result = $this->db->sql_query($sub_sql);
                 while ($sub_row = $this->db->sql_fetchrow($sub_result)) {
                     if ($sub_row['button_only_registered'] && $this->user->data['user_id'] == ANONYMOUS || $sub_row['button_only_guest'] && $this->user->data['user_id'] != ANONYMOUS) {
                         continue;
                     }
                     if (preg_match("/\\{(.*)\\}/", $sub_row['button_url'])) {
                         $brackets = array("{", "}");
                         $var_name = strtoupper(str_replace($brackets, '', $sub_row['button_url']));
                         $sub_row['button_url'] = $rootref[$var_name];
                     }
                     if (preg_match("/\\{(.*)\\}/", $sub_row['button_name'])) {
                         $brackets = array("{L_", "}");
                         $var_name = strtoupper(str_replace($brackets, '', $sub_row['button_name']));
                         $sub_row['button_name'] = $this->user->lang[$var_name];
                     }
                     $this->template->assign_block_vars('buttons.sub', array('ID' => $sub_row['button_id'], 'URL' => $sub_row['button_url'], 'NAME' => $sub_row['button_name'], 'EXTERNAL' => $sub_row['button_external']));
                 }
                 $this->db->sql_freeresult($sub_result);
             }
             $this->db->sql_freeresult($result);
         }
     }
 }
Example #2
Show file File: ContainerBuilderTest.php Project: juraj-blahunka/Bachelor-Thesis
0
 public function testGetNotedDefinitions_WithDefinedNotes()
 {
     $definitions = array();
     $definitions[] = $this->object->define('NewComponent')->addNote('controller.load', 'resolve');
     $definitions[] = $this->object->define('AnoterLoader')->addNotes(array('controller.load' => 'resolve', 'another.load' => 'resolve_another'));
     $this->assertThat($this->object->getNotedDefinitions('controller.load'), $this->equalTo($definitions));
 }
Example #3
Show file File: ContainerBuilderTest.php Project: watsonad/opendocman
0
 public function testNewInstance()
 {
     $builder = new ContainerBuilder();
     $preset_service = (object) array('irk' => 'doom');
     $services = array('preset_service' => $preset_service);
     $config_classes = array('Aura\\Di\\FakeLibraryConfig', 'Aura\\Di\\FakeProjectConfig');
     $di = $builder->newInstance($services, $config_classes);
     $this->assertInstanceOf('Aura\\Di\\Container', $di);
     $this->assertSame($preset_service, $di->get('preset_service'));
     $expect = 'zim';
     $actual = $di->get('library_service');
     $this->assertSame($expect, $actual->foo);
     $expect = 'gir';
     $actual = $di->get('project_service');
     $this->assertSame($expect, $actual->baz);
 }
Example #4
Show file File: acp_attachments.php Project: AkhilSharma/Serbest
0
 /**
  * Handle stats resync.
  *
  * @return null
  */
 public function handle_stats_resync()
 {
     if (!confirm_box(true)) {
         confirm_box(false, $this->user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array('i' => $this->id, 'mode' => 'manage', 'action' => 'stats')));
     } else {
         $this->set_attachment_stats($this->get_attachment_stats());
         $log = $this->src_container->get('log');
         $log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_RESYNC_FILES_STATS');
     }
 }
Example #5
Show file File: DoctrineMongoDBBundle.php Project: khalid05/symfony
0
 /**
  * Customizes the Container instance.
  *
  * @param \Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag A ParameterBagInterface instance
  *
  * @return \Symfony\Components\DependencyInjection\ContainerBuilder A ContainerBuilder instance
  */
 public function buildContainer(ParameterBagInterface $parameterBag)
 {
     ContainerBuilder::registerExtension(new MongoDBExtension($parameterBag->get('kernel.bundle_dirs'), $parameterBag->get('kernel.bundles'), $parameterBag->get('kernel.cache_dir')));
 }
Example #6
Show file File: PropelBundle.php Project: khalid05/symfony
0
 /**
  * Customizes the Container instance.
  *
  * @param \Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag A ParameterBagInterface instance
  *
  * @return \Symfony\Components\DependencyInjection\ContainerBuilder A ContainerBuilder instance
  */
 public function buildContainer(ParameterBagInterface $parameterBag)
 {
     ContainerBuilder::registerExtension(new PropelExtension());
 }
Example #7
Show file File: ContainerBuilderTest.php Project: AdrenalineHunter/AWSBundle
0
 public function beforeTestMethod($method)
 {
     parent::beforeTestMethod($method);
     $this->container = new \mock\Symfony\Component\DependencyInjection\ContainerBuilder();
     $this->container->setParameter('test', true);
 }
Example #8
Show file File: SfContainerInitializer.php Project: avalonia-project/sf-container
0
 protected function registerContainerConfiguration(KernelInterface $kernel, ContainerBuilder $containerBuilder, LoaderInterface $loader)
 {
     // Register core services
     $containerBuilder->register("kernel", KernelInterface::class)->setSynthetic(true);
     $containerBuilder->register("event_dispatcher", EventDispatcher::class);
     $containerBuilder->register("kernel.task_collection", TaskCollection::class);
     // Then core compiler passes
     $containerBuilder->addCompilerPass(new RegisterListenersPass())->addCompilerPass(new RegisterTasksPass());
     // Register modules configuration
     foreach ($kernel->getRegisteredModules() as $module) {
         if ($module instanceof SfContainerInitializerModuleInterface) {
             $module->buildContainer($containerBuilder);
             if (null !== ($cont = $module->registerContainerConfiguration($loader))) {
                 $containerBuilder->merge($cont);
             }
         }
     }
 }
Example #9
Show file File: DependencyInjectionContainer.php Project: juraj-blahunka/Bachelor-Thesis
0
 /**
  * Merge settings and created component adapters from other container
  *
  * @param DependencyInjectionContainer $container
  */
 public function merge($container)
 {
     parent::merge($container);
     if ($container instanceof self) {
         $this->adapters = array_merge($this->adapters, $container->adapters);
     }
 }
Example #10
Show file File: Application.php Project: garyr/portunus
0
 public static function createDb(ContainerBuilder $container = null)
 {
     if (!$container) {
         $container = new ContainerBuilder();
     }
     $dataDir = Application::resolveRelativePath($container->getParameter('doctrine.db.data_dir'));
     if (!is_dir($dataDir)) {
         $result = mkdir($dataDir, 0777, true);
         if (!$result) {
             throw new \Exception('Error creating Portunus data dir');
         }
     }
     $dev = $container->getParameter('portunus.dev');
     $container->setParameter('protunus.dev', true);
     // schema creation requires dev mode
     $metadata = $container->get('doctrine.entity_manager')->getMetadataFactory()->getAllMetadata();
     // create db if not exists
     $dbName = $container->getParameter('doctrine.db.filename');
     $portunusDB = sprintf('%s/%s', $dataDir, $dbName);
     if (!file_exists($portunusDB)) {
         $container->get('doctrine.schema_tool')->createSchema($metadata);
     }
     // create proxy classes if not exist
     $cacheDir = $container->get('portunus.application')->getCacheDir();
     $cacheFiles = glob($cacheDir . '/__CG__*.php');
     if (count($cacheFiles) < 1) {
         $cacheDir = $container->get('portunus.application')->getCacheDir();
         $container->get('doctrine.entity_manager')->getProxyFactory()->generateProxyClasses($metadata, $cacheDir);
     }
     $container->setParameter('protunus.dev', $dev);
 }
Example #11
Show file File: SfContainerInitializer.php Project: lovenunu/avalonia
0
 /**
  * Gets a new ContainerBuilder instance used to build the service container.
  *
  * @param KernelInterface $kernel
  * @return ContainerBuilder
  */
 protected function getContainerBuilder(KernelInterface $kernel)
 {
     $containerBuilder = new ContainerBuilder(new ParameterBag($this->getKernelParameters($kernel)));
     if (class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\Instantiator\\RuntimeInstantiator')) {
         $containerBuilder->setProxyInstantiator(new RuntimeInstantiator());
     }
     return $containerBuilder;
 }
Example #12
Show file File: AppKernel.php Project: aeshion/ZeroPHP
0
 public function initAppServiceContainer($container_class = 'AppServiceContainer')
 {
     $builder = new ContainerBuilder();
     $configuration = AppKernel::getInstance()->getConfiguration();
     $parameters = $configuration->parameters;
     $parameters = $parameters->toArray();
     $parameters = $builder->resolveValue($parameters, array('parameters' => $parameters));
     $parameters = new Configuration($parameters);
     $configuration->parameters = $parameters;
     if (!isset($this->_serviceContainer)) {
         $container_path = CACHE_ROOT . '/' . $container_class . '.php';
         if (!file_exists($container_path) || ENV != 'online') {
             $builder->setClassName($container_class);
             $builder->setPath($container_path);
             $builder->dump($this->getConfiguration());
         }
         require_once $container_path;
         $this->_serviceContainer = call_user_func(array($container_class, 'getInstance'));
     }
 }
Frequently Used Methods