本文整理汇总了PHP中Sylius\Component\Registry\ServiceRegistryInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ServiceRegistryInterface类的具体用法?PHP ServiceRegistryInterface怎么用?PHP ServiceRegistryInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceRegistryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Parameters
function it_throws_an_exception_if_driver_is_not_supported(Grid $grid, ServiceRegistryInterface $driversRegistry)
{
$parameters = new Parameters();
$grid->getDriver()->willReturn('doctrine/banana');
$driversRegistry->has('doctrine/banana')->willReturn(false);
$this->shouldThrow(new UnsupportedDriverException('doctrine/banana'))->during('getDataSource', [$grid, $parameters]);
}
示例2:
function it_renders_field_with_data_via_appriopriate_field_type(GridView $gridView, Field $field, ServiceRegistryInterface $fieldsRegistry, FieldTypeInterface $fieldType)
{
$field->getType()->willReturn('string');
$fieldsRegistry->get('string')->willReturn($fieldType);
$fieldType->render($field, 'Value')->willReturn('<strong>Value</strong>');
$this->renderField($gridView, $field, 'Value')->shouldReturn('<strong>Value</strong>');
}
示例3:
function it_should_create_a_form_for_given_schema_namespace(FormInterface $form, FormBuilder $formBuilder, FormFactoryInterface $formFactory, SchemaInterface $schema, ServiceRegistryInterface $schemaRegistry)
{
$schemaRegistry->get('sylius_general')->willReturn($schema);
$formFactory->createBuilder('form', null, ['data_class' => null])->willReturn($formBuilder);
$schema->buildForm($formBuilder)->shouldBeCalled()->willReturn($formBuilder);
$formBuilder->getForm()->willReturn($form);
$this->create('sylius_general')->shouldReturn($form);
}
示例4:
function it_builds_prototypes(FormBuilderInterface $builder, FormBuilderInterface $prototype, FormInterface $form, ServiceRegistryInterface $registry)
{
$registry->all()->willReturn(['configuration_kind' => '']);
$builder->create('name', 'sylius_promotion_action', ['configuration_type' => 'configuration_kind'])->willReturn($prototype);
$prototype->getForm()->willReturn($form);
$builder->setAttribute('prototypes', ['configuration_kind' => $form])->shouldBeCalled();
$this->buildForm($builder, ['registry' => $registry, 'prototype_name' => 'name', 'type' => 'sylius_promotion_action', 'options' => []]);
}
示例5:
function it_should_delegate_calculation_to_a_calculator_defined_on_shipping_method(ServiceRegistryInterface $registry, ShipmentInterface $shipment, ShippingMethodInterface $method, CalculatorInterface $calculator)
{
$shipment->getMethod()->willReturn($method);
$method->getCalculator()->willReturn('default');
$method->getConfiguration()->willReturn([]);
$registry->get('default')->willReturn($calculator);
$calculator->calculate($shipment, [])->shouldBeCalled()->willReturn(1000);
$this->calculate($shipment, [])->shouldReturn(1000);
}
示例6:
function it_registers_theme_schema_alias_if_not_exists_during_loading_settings(SettingsManagerInterface $decoratedSettingsManager, ServiceRegistryInterface $schemaRegistry, ThemeSettingsSchemaProviderInterface $themeSettingsSchemaProvider, ThemeInterface $theme, SettingsInterface $settings, SchemaInterface $schema)
{
$theme->getName()->willReturn('theme/name');
$schemaRegistry->has('theme_theme/name')->willReturn(false);
$themeSettingsSchemaProvider->getSchema($theme)->willReturn($schema);
$schemaRegistry->register('theme_theme/name', $schema)->shouldBeCalled();
$decoratedSettingsManager->load('theme_theme/name', null)->willReturn($settings);
$this->load($theme)->shouldReturn($settings);
}
示例7: create
/**
* {@inheritdoc}
*/
public function create($schemaAlias, $data = null, array $options = [])
{
$schema = $this->schemaRegistry->get($schemaAlias);
$builder = $this->formFactory->createBuilder('form', $data, array_merge_recursive(['data_class' => null], $options));
$schema->buildForm($builder);
return $builder->getForm();
}
示例8: addConfigurationFields
/**
* @param FormInterface $form
* @param string $ruleType
* @param array $data
*/
protected function addConfigurationFields(FormInterface $form, $ruleType, array $data = [])
{
/** @var RuleCheckerInterface $checker */
$checker = $this->checkerRegistry->get($ruleType);
$configurationField = $this->factory->createNamed('configuration', $checker->getConfigurationFormType(), $data, ['auto_initialize' => false]);
$form->add($configurationField);
}
示例9: get
/**
* {@inheritdoc}
*/
public function get($type)
{
if (!$this->decoratedRegistry->has($type)) {
return $this->defaultResolver;
}
return $this->decoratedRegistry->get($type);
}
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new AddCodeFormSubscriber())->addEventSubscriber(new BuildReportDataFetcherFormSubscriber($this->dataFetcherRegistry, $builder->getFormFactory()))->addEventSubscriber(new BuildReportRendererFormSubscriber($this->rendererRegistry, $builder->getFormFactory()))->add('name', 'text', ['label' => 'sylius.form.report.name', 'required' => true])->add('description', 'textarea', ['label' => 'sylius.form.report.description', 'required' => false])->add('dataFetcher', 'sylius_data_fetcher_choice', ['label' => 'sylius.form.report.data_fetcher'])->add('renderer', 'sylius_renderer_choice', ['label' => 'sylius.form.report.renderer.label']);
$prototypes = ['renderers' => [], 'dataFetchers' => []];
foreach ($this->rendererRegistry->all() as $type => $renderer) {
$formType = sprintf('sylius_renderer_%s', $renderer->getType());
if (!$formType) {
continue;
}
try {
$prototypes['renderers'][$type] = $builder->create('rendererConfiguration', $formType)->getForm();
} catch (\InvalidArgumentException $e) {
continue;
}
}
foreach ($this->dataFetcherRegistry->all() as $type => $dataFetcher) {
$formType = sprintf('sylius_data_fetcher_%s', $dataFetcher->getType());
if (!$formType) {
continue;
}
try {
$prototypes['dataFetchers'][$type] = $builder->create('dataFetcherConfiguration', $formType)->getForm();
} catch (\InvalidArgumentException $e) {
continue;
}
}
$builder->setAttribute('prototypes', $prototypes);
}
示例11: apply
/**
* {@inheritdoc}
*/
public function apply(DataSourceInterface $dataSource, Grid $grid, Parameters $parameters)
{
if ($parameters->has(ResourceOwnerFilter::TYPE)) {
$this->filtersRegistry->get(ResourceOwnerFilter::TYPE)->apply($dataSource, ResourceOwnerFilter::FIELD, $parameters->get(ResourceOwnerFilter::TYPE), []);
}
return $this->filtersApplicator->apply($dataSource, $grid, $parameters);
}
示例12: getDataSource
/**
* {@inheritdoc}
*/
public function getDataSource(Grid $grid, Parameters $parameters)
{
$driver = $grid->getDriver();
if (!$this->driversRegistry->has($driver)) {
throw new UnsupportedDriverException($driver);
}
return $this->driversRegistry->get($driver)->getDataSource($grid->getDriverConfiguration(), $parameters);
}
示例13: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof AttributeValueInterface) {
throw new UnexpectedTypeException(get_class($value), AttributeValueInterface::class);
}
$attributeType = $this->attributeTypeRegistry->get($value->getType());
$attributeType->validate($value, $this->context, $value->getAttribute()->getConfiguration());
}
示例14: renderField
/**
* @param Field $field
* @param $data
*/
public function renderField(GridView $gridView, Field $field, $data)
{
$fieldType = $this->fieldsRegistry->get($field->getType());
$resolver = new OptionsResolver();
$fieldType->configureOptions($resolver);
$options = $resolver->resolve($field->getOptions());
return $fieldType->render($field, $data, $options);
}
示例15: calculate
/**
* {@inheritdoc}
*/
public function calculate(PriceableInterface $subject, array $context = array())
{
if (null === ($type = $subject->getPricingCalculator())) {
throw new \InvalidArgumentException('Cannot calculate the price for PriceableInterface instance without calculator defined.');
}
$calculator = $this->registry->get($type);
return $calculator->calculate($subject, $subject->getPricingConfiguration(), $context);
}