本文整理汇总了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::getDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataInterface::getDriver方法的具体用法?PHP MetadataInterface::getDriver怎么用?PHP MetadataInterface::getDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::getDriver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_defines_resource_options(OptionsResolver $resolver, MetadataInterface $metadata)
{
$metadata->getDriver()->willReturn(SyliusResourceBundle::DRIVER_DOCTRINE_ORM);
$resolver->setDefaults(['class' => null])->shouldBeCalled()->willReturn($resolver);
$resolver->setNormalizer('class', Argument::type('callable'))->shouldBeCalled()->willReturn($resolver);
$this->configureOptions($resolver);
}
示例2: get
/**
* @param MetadataInterface $metadata
*
* @return DriverInterface
*
* @throws UnknownDriverException
*/
public static function get(MetadataInterface $metadata)
{
$type = $metadata->getDriver();
if (isset(self::$drivers[$type])) {
return self::$drivers[$type];
}
switch ($type) {
case SyliusResourceBundle::DRIVER_DOCTRINE_ORM:
return self::$drivers[$type] = new DoctrineORMDriver();
case SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM:
return self::$drivers[$type] = new DoctrineODMDriver();
case SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM:
return self::$drivers[$type] = new DoctrinePHPCRDriver();
}
throw new UnknownDriverException($type);
}
示例3: getParent
/**
* {@inheritdoc}
*/
public function getParent()
{
return $this->getFormTypeForDriver($this->metadata->getDriver());
}
示例4: debugResource
/**
* @param MetadataInterface $metadata
* @param OutputInterface $output
*/
private function debugResource(MetadataInterface $metadata, OutputInterface $output)
{
$table = new Table($output);
$information = ['name' => $metadata->getName(), 'application' => $metadata->getApplicationName(), 'driver' => $metadata->getDriver()];
$parameters = $this->flattenParameters($metadata->getParameters());
foreach ($parameters as $key => $value) {
$information[$key] = $value;
}
foreach ($information as $key => $value) {
$table->addRow([$key, $value]);
}
$table->render();
}
示例5: addForms
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function addForms(ContainerBuilder $container, MetadataInterface $metadata)
{
foreach ($metadata->getClass('form') as $formName => $formClass) {
$suffix = 'default' === $formName ? '' : sprintf('_%s', $formName);
$alias = sprintf('%s_%s%s', $metadata->getApplicationName(), $metadata->getName(), $suffix);
$definition = new Definition($formClass);
switch ($formName) {
case 'choice':
$definition->setArguments([$metadata->getClass('model'), $metadata->getDriver(), $alias]);
break;
default:
$validationGroupsParameterName = sprintf('%s.validation_groups.%s%s', $metadata->getApplicationName(), $metadata->getName(), $suffix);
$validationGroups = new Parameter($validationGroupsParameterName);
if (!$container->hasParameter($validationGroupsParameterName)) {
$validationGroups = ['Default'];
}
$definition->setArguments([$metadata->getClass('model'), $validationGroups]);
break;
}
$definition->addTag('form.type', ['alias' => $alias]);
$container->setParameter(sprintf('%s.form.type.%s%s.class', $metadata->getApplicationName(), $metadata->getName(), $suffix), $formClass);
$container->setDefinition(sprintf('%s.form.type.%s%s', $metadata->getApplicationName(), $metadata->getName(), $suffix), $definition);
}
if (!$container->hasDefinition(sprintf('%s.form.type.%s', $metadata->getApplicationName(), $metadata->getName()))) {
$this->addDefaultForm($container, $metadata);
}
}