本文整理匯總了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::hasClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP MetadataInterface::hasClass方法的具體用法?PHP MetadataInterface::hasClass怎麽用?PHP MetadataInterface::hasClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::hasClass方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setClassesParameters
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function setClassesParameters(ContainerBuilder $container, MetadataInterface $metadata)
{
if ($metadata->hasClass('model')) {
$container->setParameter(sprintf('%s.model.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('model'));
}
if ($metadata->hasClass('controller')) {
$container->setParameter(sprintf('%s.controller.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('controller'));
}
if ($metadata->hasClass('factory')) {
$container->setParameter(sprintf('%s.factory.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('factory'));
}
if ($metadata->hasClass('repository')) {
$container->setParameter(sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('repository'));
}
}
示例2: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$reflection = new \ReflectionClass($metadata->getClass('model'));
$translatableInterface = TranslatableInterface::class;
$translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
$repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
$repositoryClass = $translatable ? TranslatableResourceRepository::class : EntityRepository::class;
if ($container->hasParameter($repositoryClassParameterName)) {
$repositoryClass = $container->getParameter($repositoryClassParameterName);
}
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$repositoryReflection = new \ReflectionClass($repositoryClass);
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
$definition->setLazy(!$repositoryReflection->isFinal());
if ($metadata->hasParameter('translation')) {
$translatableRepositoryInterface = TranslatableResourceRepositoryInterface::class;
$translationConfig = $metadata->getParameter('translation');
if (interface_exists($translatableRepositoryInterface) && $repositoryReflection->implementsInterface($translatableRepositoryInterface)) {
if (isset($translationConfig['fields'])) {
$definition->addMethodCall('setTranslatableFields', [$translationConfig['fields']]);
}
}
}
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例3: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$reflection = new \ReflectionClass($metadata->getClass('model'));
$translatableInterface = 'Sylius\\Component\\Translation\\Model\\TranslatableInterface';
$translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
$repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
$repositoryClass = $translatable ? 'Sylius\\Bundle\\TranslationBundle\\Doctrine\\ORM\\TranslatableResourceRepository' : 'Sylius\\Bundle\\ResourceBundle\\Doctrine\\ORM\\EntityRepository';
if ($container->hasParameter($repositoryClassParameterName)) {
$repositoryClass = $container->getParameter($repositoryClassParameterName);
}
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)));
if ($metadata->hasParameter('translation')) {
$repositoryReflection = new \ReflectionClass($repositoryClass);
$translatableRepositoryInterface = 'Sylius\\Component\\Translation\\Repository\\TranslatableResourceRepositoryInterface';
$translationConfig = $metadata->getParameter('translation');
if (interface_exists($translatableRepositoryInterface) && $repositoryReflection->implementsInterface($translatableRepositoryInterface)) {
if (isset($translationConfig['fields'])) {
$definition->addMethodCall('setTranslatableFields', array($translationConfig['fields']));
}
}
}
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例4: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClass = new Parameter('sylius.phpcr_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)));
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例5: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$modelClass = $metadata->getClass('model');
$repositoryClass = in_array(TranslatableInterface::class, class_implements($modelClass)) ? TranslatableRepository::class : new Parameter('sylius.mongodb.odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
$unitOfWorkDefinition->setFactory([new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'])->setPublic(false);
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($metadata)]);
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例6: setClassesParameters
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function setClassesParameters(ContainerBuilder $container, MetadataInterface $metadata)
{
if ($metadata->hasClass('model')) {
$container->setParameter(sprintf('%s.model.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('model'));
}
if ($metadata->hasClass('controller')) {
$container->setParameter(sprintf('%s.controller.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('controller'));
}
if ($metadata->hasClass('factory')) {
$container->setParameter(sprintf('%s.factory.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('factory'));
}
if ($metadata->hasClass('repository')) {
$container->setParameter(sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('repository'));
}
if (!$metadata->hasParameter('validation_groups')) {
return;
}
$validationGroups = $metadata->getParameter('validation_groups');
foreach ($validationGroups as $formName => $groups) {
$suffix = 'default' === $formName ? '' : sprintf('_%s', $formName);
$container->setParameter(sprintf('%s.validation_groups.%s%s', $metadata->getApplicationName(), $metadata->getName(), $suffix), array_merge(['Default'], $groups));
}
}
示例7: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
$repositoryClass = EntityRepository::class;
if ($container->hasParameter($repositoryClassParameterName)) {
$repositoryClass = $container->getParameter($repositoryClassParameterName);
}
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例8: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$modelClass = $metadata->getClass('model');
$reflection = new \ReflectionClass($modelClass);
$translatableInterface = 'Sylius\\Component\\Translation\\Model\\TranslatableInterface';
$translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
$repositoryClass = $translatable ? 'Sylius\\Bundle\\TranslationBundle\\Doctrine\\ODM\\MongoDB\\TranslatableResourceRepository' : new Parameter('sylius.mongodb_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
$unitOfWorkDefinition->setFactory(array(new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'))->setPublic(false);
$definition = new Definition($repositoryClass);
$definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($modelClass)));
return $definition;
}
示例9: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$modelClass = $metadata->getClass('model');
$reflection = new \ReflectionClass($modelClass);
$translatableInterface = TranslatableInterface::class;
$translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
$repositoryClass = $translatable ? TranslatableResourceRepository::class : new Parameter('sylius.mongodb_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$repositoryReflection = new \ReflectionClass($repositoryClass);
$unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
$unitOfWorkDefinition->setFactory([new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'])->setPublic(false);
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($metadata)]);
$definition->setLazy(!$repositoryReflection->isFinal());
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例10: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClass = new Parameter('sylius.phpcr_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$repositoryReflection = new \ReflectionClass($repositoryClass);
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
$definition->setLazy(!$repositoryReflection->isFinal());
if ($metadata->hasParameter('translation')) {
$translationConfig = $metadata->getParameter('translation');
if (in_array(TranslatableRepositoryInterface::class, class_implements($repositoryClass))) {
if (isset($translationConfig['fields'])) {
$definition->addMethodCall('setTranslatableFields', [$translationConfig['fields']]);
}
}
}
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}