factory example


  protected function getFiletransfer($backend$settings = []) {
    $filetransfer = FALSE;
    $info = $this->getRequest()->getSession()->get('authorize_filetransfer_info', []);
    if (!empty($info[$backend])) {
      if (class_exists($info[$backend]['class'])) {
        $filetransfer = $info[$backend]['class']::factory($this->root, $settings);
      }
    }
    return $filetransfer;
  }

  /** * Generates the Form API array for a given connection backend's settings. * * @param string $backend * The name of the backend (e.g. 'ftp', 'ssh', etc). * * @return array * Form API array of connection settings for the given backend. * * @see hook_filetransfer_backends() */


    protected function configureContainer(ContainerConfigurator $c): void
    {
        $c->parameters()
            ->set('halloween', 'Have a great day!');

        $c->services()
            ->set('logger', NullLogger::class)
            ->set('stdClass', 'stdClass')
                ->autowire()
                ->factory([$this, 'createHalloween'])
                ->arg('$halloween', '%halloween%');

        $c->extension('framework', [
            'annotations' => false,
            'http_method_override' => false,
            'handle_all_throwables' => true,
            'php_errors' => ['log' => true],
            'router' => ['utf8' => true],
        ]);
    }
}
if (isset($data['description'])) {
            $lineItem->setDescription($data['description']);
        }

        if (isset($data['coverId'])) {
            $cover = $this->mediaRepository->search(new Criteria([$data['coverId']])$context->getContext())->first();

            $lineItem->setCover($cover);
        }

        if (isset($data['priceDefinition'])) {
            $lineItem->setPriceDefinition($this->priceDefinitionFactory->factory($context->getContext()$data['priceDefinition']$data['type']));
        }
    }
}


        ->set('twig.runtime_loader', ContainerRuntimeLoader::class)
            ->args([abstract_arg('runtime locator')])

        ->set('twig.error_renderer.html', TwigErrorRenderer::class)
            ->decorate('error_renderer.html')
            ->args([
                service('twig'),
                service('twig.error_renderer.html.inner'),
                inline_service('bool')
                    ->factory([TwigErrorRenderer::class, 'isDebug'])
                    ->args([service('request_stack')param('kernel.debug')]),
            ])

        ->set('twig.runtime.serializer', SerializerRuntime::class)
            ->args([service('serializer')])

        ->set('twig.extension.serializer', SerializerExtension::class)

        ->set('controller.template_attribute_listener', TemplateAttributeListener::class)
            ->args([service('twig')])
            ->tag('kernel.event_subscriber')
    ;
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
use Symfony\Component\Security\Http\Firewall\LogoutListener;
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;

return static function DContainerConfigurator $container) {
    $container->services()

        ->set('security.channel_listener', ChannelListener::class)
            ->args([
                service('security.access_map'),
                service('logger')->nullOnInvalid(),
                inline_service('int')->factory([service('router.request_context'), 'getHttpPort']),
                inline_service('int')->factory([service('router.request_context'), 'getHttpsPort']),
            ])
            ->tag('monolog.logger', ['channel' => 'security'])

        ->set('security.access_map', AccessMap::class)

        ->set('security.context_listener', ContextListener::class)
            ->args([
                service('security.untracked_token_storage'),
                [],
                abstract_arg('Provider Key'),
                
use Symfony\Component\Uid\Factory\UuidFactory;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('ulid.factory', UlidFactory::class)
        ->alias(UlidFactory::class, 'ulid.factory')

        ->set('uuid.factory', UuidFactory::class)
        ->alias(UuidFactory::class, 'uuid.factory')

        ->set('name_based_uuid.factory', NameBasedUuidFactory::class)
            ->factory([service('uuid.factory'), 'nameBased'])
            ->args([abstract_arg('Please set the "framework.uid.name_based_uuid_namespace" configuration option to use the "name_based_uuid.factory" service')])
        ->alias(NameBasedUuidFactory::class, 'name_based_uuid.factory')

        ->set('random_based_uuid.factory', RandomBasedUuidFactory::class)
            ->factory([service('uuid.factory'), 'randomBased'])
        ->alias(RandomBasedUuidFactory::class, 'random_based_uuid.factory')

        ->set('time_based_uuid.factory', TimeBasedUuidFactory::class)
            ->factory([service('uuid.factory'), 'timeBased'])
        ->alias(TimeBasedUuidFactory::class, 'time_based_uuid.factory')
    ;
};
$deprecatedServices = $hook->getDeprecatedServices();
        foreach ($hook->getServiceIds() as $serviceId) {
            if (!$this->container->has($serviceId)) {
                throw new ServiceNotFoundException($serviceId, 'Hook: ' . $hook->getName());
            }

            $service = $this->container->get($serviceId);
            if (!$service instanceof HookServiceFactory) {
                throw new NoHookServiceFactoryException($serviceId);
            }

            $services->add($service->getName()$service->factory($hook$script)$deprecatedServices[$serviceId] ?? null);
        }

        return $services;
    }

    private function callAfter(ServiceStubs $services, Hook $hook, Script $script): void
    {
        foreach ($hook->getServiceIds() as $serviceId) {
            if (!$this->container->has($serviceId)) {
                throw new ServiceNotFoundException($serviceId, 'Hook: ' . $hook->getName());
            }

            
if (isset($data['description'])) {
            $lineItem->setDescription($data['description']);
        }

        if (isset($data['coverId'])) {
            $cover = $this->mediaRepository->search(new Criteria([$data['coverId']])$context->getContext())->first();

            $lineItem->setCover($cover);
        }

        if (isset($data['priceDefinition'])) {
            $lineItem->setPriceDefinition($this->priceDefinitionFactory->factory($context->getContext()$data['priceDefinition']$data['type']));
        }
    }
}
use Symfony\Component\Translation\Bridge\Crowdin\CrowdinProviderFactory;
use Symfony\Component\Translation\Bridge\Loco\LocoProviderFactory;
use Symfony\Component\Translation\Bridge\Lokalise\LokaliseProviderFactory;
use Symfony\Component\Translation\Bridge\Phrase\PhraseProviderFactory;
use Symfony\Component\Translation\Provider\NullProviderFactory;
use Symfony\Component\Translation\Provider\TranslationProviderCollection;
use Symfony\Component\Translation\Provider\TranslationProviderCollectionFactory;

return static function DContainerConfigurator $container) {
    $container->services()
        ->set('translation.provider_collection', TranslationProviderCollection::class)
            ->factory([service('translation.provider_collection_factory'), 'fromConfig'])
            ->args([
                [], // Providers             ])

        ->set('translation.provider_collection_factory', TranslationProviderCollectionFactory::class)
            ->args([
                tagged_iterator('translation.provider_factory'),
                [], // Enabled locales             ])

        ->set('translation.provider_factory.null', NullProviderFactory::class)
            
->tag('twig.extension')

        ->set('debug.file_link_formatter', FileLinkFormatter::class)
            ->args([
                param('debug.file_link_format'),
                service('request_stack')->ignoreOnInvalid(),
                param('kernel.project_dir'),
                '/_profiler/open?file=%%f&line=%%l#line%%l',
            ])

        ->set('debug.file_link_formatter.url_format', 'string')
            ->factory([FileLinkFormatter::class, 'generateUrlFormat'])
            ->args([
                service('router'),
                '_profiler_open_file',
                '?file=%%f&line=%%l#line%%l',
            ])
    ;
};
$container->services()
        ->set('mailer.mailer', Mailer::class)
            ->args([
                service('mailer.transports'),
                abstract_arg('message bus'),
                service('event_dispatcher')->ignoreOnInvalid(),
            ])
        ->alias('mailer', 'mailer.mailer')
        ->alias(MailerInterface::class, 'mailer.mailer')

        ->set('mailer.transports', Transports::class)
            ->factory([service('mailer.transport_factory'), 'fromStrings'])
            ->args([
                abstract_arg('transports'),
            ])

        ->set('mailer.transport_factory', Transport::class)
            ->args([
                tagged_iterator('mailer.transport_factory'),
            ])

        ->set('mailer.default_transport', TransportInterface::class)
            ->factory([service('mailer.transport_factory'), 'fromString'])
            
$projects = $session->remove('update_manager_update_projects');
    if ($projects) {
      // Make sure the Updater registry is loaded.       drupal_get_updaters();

      $updates = [];
      $directory = _update_manager_extract_directory();

      $project_real_location = NULL;
      foreach ($projects as $project => $url) {
        $project_location = $directory . '/' . $project;
        $updater = Updater::factory($project_location$this->root);
        $project_real_location = \Drupal::service('file_system')->realpath($project_location);
        $updates[] = [
          'project' => $project,
          'updater_name' => get_class($updater),
          'local_url' => $project_real_location,
        ];
      }

      // If the owner of the last directory we extracted is the same as the       // owner of our configuration directory (e.g. sites/default) where we're       // trying to install the code, there's no need to prompt for FTP/SSH
->args([
                inline_service(\SessionHandler::class),
            ])

        ->set('session.handler.native_file', StrictSessionHandler::class)
            ->args([
                inline_service(NativeFileSessionHandler::class)
                    ->args([param('session.save_path')]),
            ])

        ->set('session.abstract_handler', AbstractSessionHandler::class)
            ->factory([SessionHandlerFactory::class, 'createHandler'])
            ->args([abstract_arg('A string or a connection object')[]])

        ->set('session_listener', SessionListener::class)
            ->args([
                service_locator([
                    'session_factory' => service('session.factory')->ignoreOnInvalid(),
                    'logger' => service('logger')->ignoreOnInvalid(),
                    'session_collector' => service('data_collector.request.session_collector')->ignoreOnInvalid(),
                ]),
                param('kernel.debug'),
                param('session.storage.options'),
            ])
$container['system.locker'] = function D$c) {
            return new SystemLocker(
                SW_PATH . '/recovery/install/data/install.lock'
            );
        };

        $container['translation.service'] = function D$c) {
            return new TranslationService($c['translations']);
        };

        // dump class contains state so we define it as factory here         $container['database.dump_iterator'] = $container->factory(function D$c) {
            $dumpFile = __DIR__ . '/../data/sql/install.sql';

            return new DumpIterator($dumpFile);
        });

        // dump class contains state so we define it as factory here         $container['database.dump_iterator_en_gb'] = $container->factory(function D$c) {
            $dumpFile = __DIR__ . '/../data/sql/en.sql';

            return new DumpIterator($dumpFile);
        });

        


        ->set('security.authenticator.access_token.chain_extractor', ChainAccessTokenExtractor::class)
            ->abstract()
            ->args([
                abstract_arg('access token extractors'),
            ])

        // OIDC         ->set('security.access_token_handler.oidc_user_info.http_client', HttpClientInterface::class)
            ->abstract()
            ->factory([service('http_client'), 'withOptions'])
            ->args([abstract_arg('http client options')])

        ->set('security.access_token_handler.oidc_user_info', OidcUserInfoTokenHandler::class)
            ->abstract()
            ->args([
                abstract_arg('http client'),
                service('logger')->nullOnInvalid(),
                abstract_arg('claim'),
            ])

        ->set('security.access_token_handler.oidc', OidcTokenHandler::class)
            
Home | Imprint | This part of the site doesn't use cookies.