本文整理汇总了PHP中Sylius\Component\Registry\ServiceRegistryInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceRegistryInterface::get方法的具体用法?PHP ServiceRegistryInterface::get怎么用?PHP ServiceRegistryInterface::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Registry\ServiceRegistryInterface
的用法示例。
在下文中一共展示了ServiceRegistryInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: get
/**
* {@inheritdoc}
*/
public function get($type)
{
if (!$this->decoratedRegistry->has($type)) {
return $this->defaultResolver;
}
return $this->decoratedRegistry->get($type);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: render
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException If the report subject does not have a renderer.
*/
public function render(ReportInterface $subject, Data $data)
{
if (null === ($type = $subject->getRenderer())) {
throw new \InvalidArgumentException('Cannot render data for ReportInterface instance without renderer defined.');
}
$renderer = $this->registry->get($type);
return $renderer->render($subject, $data);
}
示例8: 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());
}
示例9: 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);
}
示例10: calculate
/**
* {@inheritdoc}
*/
public function calculate(ShippingSubjectInterface $subject)
{
if (null === ($method = $subject->getMethod())) {
throw new UndefinedShippingMethodException('Cannot calculate charge for shipping subject without defined shipping method.');
}
$calculator = $this->registry->get($method->getCalculator());
return $calculator->calculate($subject, $method->getConfiguration());
}
示例11: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(['resource' => null, 'choices' => function (Options $options) {
return $options['function']($this->resourceRepositoryRegistry->get($options['resource']), $options);
}, 'function' => function (RepositoryInterface $repository, Options $options) {
return $repository->findAll();
}])->setRequired(['resource']);
}
示例12: createTyped
/**
* {@inheritdoc}
*/
public function createTyped($type)
{
/** @var AttributeTypeInterface $attributeType */
$attributeType = $this->attributeTypesRegistry->get($type);
$attribute = $this->factory->createNew();
$attribute->setType($type);
$attribute->setStorageType($attributeType->getStorageType());
return $attribute;
}
示例13: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['multiple']) {
$builder->addModelTransformer(new ResourceToIdentifierTransformer($this->resourceRepositoryRegistry->get($options['resource']), $options['choice_value']));
}
if ($options['multiple']) {
$builder->addModelTransformer(new RecursiveTransformer(new ResourceToIdentifierTransformer($this->resourceRepositoryRegistry->get($options['resource']), $options['choice_value'])))->addViewTransformer(new CollectionToStringTransformer(','));
}
}
示例14: calculate
/**
* {@inheritdoc}
*/
public function calculate(PaymentSubjectInterface $payment)
{
if (null === $payment->getMethod()) {
throw new \InvalidArgumentException("Cannot calculate fee for payment without payment method configured.");
}
/** @var FeeCalculatorInterface $feeCalculator */
$feeCalculator = $this->serviceRegistry->get($payment->getMethod()->getFeeCalculator());
return $feeCalculator->calculate($payment, $payment->getMethod()->getFeeCalculatorConfiguration());
}
示例15: fetch
/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException If the report does not have a data fetcher.
*/
public function fetch(ReportInterface $report, array $configuration = [])
{
if (null === ($type = $report->getDataFetcher())) {
throw new \InvalidArgumentException('Cannot fetch data for ReportInterface instance without DataFetcher defined.');
}
$dataFetcher = $this->registry->get($type);
$configuration = empty($configuration) ? $report->getDataFetcherConfiguration() : $configuration;
return $dataFetcher->fetch($configuration);
}