本文整理汇总了PHP中Doctrine\Common\Persistence\ManagerRegistry类的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry类的具体用法?PHP ManagerRegistry怎么用?PHP ManagerRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManagerRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @param ConfigurationProvider $provider
* @param ManagerRegistry $registry
* @param SqlBuilder $builder
* @param MigrationFileGenerator $generator
*/
public function fire(ConfigurationProvider $provider, ManagerRegistry $registry, SqlBuilder $builder, MigrationFileGenerator $generator)
{
$configuration = $provider->getForConnection($this->option('connection'));
$em = $registry->getManager($this->option('connection'));
$connection = $configuration->getConnection();
// Overrule the filter
if ($filterExpr = $this->option('filter-expression')) {
$connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpr);
}
$fromSchema = $connection->getSchemaManager()->createSchema();
$toSchema = $this->getSchemaProvider($em)->createSchema();
// Drop tables which don't suffice to the filter regex
if ($filterExpr = $connection->getConfiguration()->getFilterSchemaAssetsExpression()) {
foreach ($toSchema->getTables() as $table) {
$tableName = $table->getName();
if (!preg_match($filterExpr, $this->resolveTableName($tableName))) {
$toSchema->dropTable($tableName);
}
}
}
$up = $builder->up($configuration, $fromSchema, $toSchema);
$down = $builder->down($configuration, $fromSchema, $toSchema);
if (!$up && !$down) {
return $this->error('No changes detected in your mapping information.');
}
$path = $generator->generate($configuration, false, false, $up, $down);
$this->line(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));
}
开发者ID:mikeSimonson,项目名称:migrations-1,代码行数:36,代码来源:DiffCommand.php
示例2: __construct
/**
* @param Factory $factory
* @param SettingsManager $settings
* @param Manager $notification
* @param ManagerRegistry $doctrine
*/
public function __construct(Factory $factory, SettingsManager $settings, Manager $notification, ManagerRegistry $doctrine)
{
$this->factory = $factory;
$this->notification = $notification;
$this->settings = $settings;
$this->entityManager = $doctrine->getManager();
}
开发者ID:csbill,项目名称:csbill,代码行数:13,代码来源:NotificationManager.php
示例3: __construct
public function __construct(ManagerRegistry $managerRegistry, ContainerInterface $container, ActivityService $activityService, LocationService $locationService)
{
$this->em = $managerRegistry->getManager();
$this->container = $container;
$this->activityService = $activityService;
$this->locationService = $locationService;
}
开发者ID:campaignchain,项目名称:core,代码行数:7,代码来源:ChannelService.php
示例4: __construct
public function __construct(ManagerRegistry $managerRegistry, Session $session, TwigEngine $templating, EZPlatformClient $restClient)
{
$this->em = $managerRegistry->getManager();
$this->session = $session;
$this->templating = $templating;
$this->restClient = $restClient;
}
开发者ID:CampaignChain,项目名称:activity-ezplatform,代码行数:7,代码来源:EZPlatformScheduleHandler.php
示例5: Parameters
function it_creates_data_source_via_doctrine_orm_query_builder(ManagerRegistry $managerRegistry, EntityManagerInterface $entityManager, EntityRepository $entityRepository, QueryBuilder $queryBuilder)
{
$managerRegistry->getManagerForClass('App:Book')->willReturn($entityManager);
$entityManager->getRepository('App:Book')->willReturn($entityRepository);
$entityRepository->createQueryBuilder('o')->willReturn($queryBuilder);
$this->getDataSource(['class' => 'App:Book'], new Parameters())->shouldHaveType(DataSource::class);
}
开发者ID:sylius,项目名称:sylius,代码行数:7,代码来源:DriverSpec.php
示例6: let
function let(ManagerRegistry $registry, ProductRepositoryInterface $repository, EntityManager $em, AttributeInterface $attribute, AttributeOptionInterface $option, AttributeOptionValueInterface $optionValue)
{
$registry->getRepository('product')->willReturn($repository);
$repository->findAllWithAttributeOption($option)->willReturn([]);
$option->getAttribute()->willReturn($attribute);
$optionValue->getOption()->willReturn($option);
}
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:AttributeOptionUpdateGuesserSpec.php
示例7: EntityNotFoundException
function it_should_throw_when_applicant_does_not_exist(ManagerRegistry $managerRegistry, ObjectManager $objectManager)
{
$id = 456;
$managerRegistry->getManagerForClass(ApplicantsRepository::ENTITY_CLASS)->shouldBeCalled()->willReturn($objectManager);
$objectManager->find(ApplicantsRepository::ENTITY_CLASS, $id)->shouldBeCalled()->willReturn(null);
$this->shouldThrow(new EntityNotFoundException("Applicant does not exist."))->duringFetchApplicant($id);
}
开发者ID:transformcore,项目名称:csr-fast-stream-domain-model,代码行数:7,代码来源:ApplicantsRepositorySpec.php
示例8: __construct
/**
* @param string $class
* @param \Doctrine\Common\Persistence\ManagerRegistry $manager_registry
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
*/
public function __construct($class, ManagerRegistry $manager_registry, EventDispatcherInterface $event_dispatcher = null)
{
$this->class = $class;
$this->event_dispatcher = $event_dispatcher;
$this->entity_manager = $manager_registry->getManagerForClass($class);
$this->entity_repository = $this->entity_manager->getRepository($class);
}
开发者ID:gitter-badger,项目名称:OAuth2ServerBundle,代码行数:12,代码来源:RefreshTokenManager.php
示例9: __construct
public function __construct(ManagerRegistry $managerRegistry, ContainerInterface $container, ActivityService $activityService)
{
$this->em = $managerRegistry->getManager();
$this->container = $container;
$this->activityService = $activityService;
$this->twigExt = $this->container->get('campaignchain.core.twig.campaignchain_core_extension');
}
开发者ID:CampaignChain,项目名称:core,代码行数:7,代码来源:LocationService.php
示例10: let
function let(ManagerRegistry $managerRegistry, TranslatableListener $translatableListener, ObjectManager $manager, ClassMetadata $translatableMetadata)
{
$managerRegistry->getManagerForClass(Argument::type('string'))->willReturn($manager);
$translatableListener->getExtendedMetadata($manager, Argument::type('string'))->willReturn($translatableMetadata);
$translatableListener->getLocale()->willReturn('en');
$this->beConstructedWith($managerRegistry, $translatableListener, new PropertyAccessor());
}
开发者ID:szymach,项目名称:admin-translatable-bundle,代码行数:7,代码来源:TranslatableSpec.php
示例11: __construct
/**
* @param ManagerRegistry $doctrine
* @param EventDispatcherInterface $dispatcher
* @param FactoryInterface $stateMachine
* @param NotificationManager $notification
*/
public function __construct(ManagerRegistry $doctrine, EventDispatcherInterface $dispatcher, FactoryInterface $stateMachine, NotificationManager $notification)
{
$this->entityManager = $doctrine->getManager();
$this->dispatcher = $dispatcher;
$this->stateMachine = $stateMachine;
$this->notification = $notification;
}
开发者ID:csbill,项目名称:csbill,代码行数:13,代码来源:InvoiceManager.php
示例12: fire
/**
* Execute the console command.
*
* @param ManagerRegistry $registry
*/
public function fire(ManagerRegistry $registry)
{
$names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
foreach ($names as $name) {
$em = $registry->getManager($name);
$cache = $em->getConfiguration()->getQueryCacheImpl();
if (!$cache) {
throw new InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
}
if ($cache instanceof ApcCache) {
throw new LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
}
if ($cache instanceof XcacheCache) {
throw new LogicException("Cannot clear XCache Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
}
$this->message('Clearing result cache entries for <info>' . $name . '</info> entity manager');
$result = $cache->deleteAll();
$message = $result ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
if ($this->option('flush')) {
$result = $cache->flushAll();
$message = $result ? 'Successfully flushed cache entries.' : $message;
}
$this->info($message);
}
}
开发者ID:Devitek,项目名称:orm,代码行数:30,代码来源:ClearQueryCacheCommand.php
示例13: getLastSyncDate
/**
* @return \DateTime|null
*/
public function getLastSyncDate()
{
$channel = $this->getChannel();
$repository = $this->managerRegistry->getRepository('OroIntegrationBundle:Status');
/**
* @var Status $status
*/
$status = $repository->findOneBy(['code' => Status::STATUS_COMPLETED, 'channel' => $channel, 'connector' => $this->getType()], ['date' => 'DESC']);
$timezone = new \DateTimeZone('UTC');
$date = new \DateTime('now', $timezone);
$context = $this->getStepExecution()->getExecutionContext();
$data = $context->get(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY) ?: [];
$context->put(ConnectorInterface::CONTEXT_CONNECTOR_DATA_KEY, array_merge($data, [self::LAST_SYNC_DATE_KEY => $date->format(\DateTime::ISO8601)]));
if (!$status) {
return null;
}
$data = $status->getData();
if (empty($data)) {
return null;
}
if (!empty($data[self::LAST_SYNC_DATE_KEY])) {
return new \DateTime($data[self::LAST_SYNC_DATE_KEY], $timezone);
}
return null;
}
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:28,代码来源:AbstractMailChimpConnector.php
示例14: postSetData
/**
* @param FormEvent $event
*/
public function postSetData(FormEvent $event)
{
$form = $event->getForm();
if ($form->getParent()) {
return;
}
if (!$form->has($this->fieldName)) {
return;
}
$isEntityExists = false;
$entity = $event->getData();
if ($entity) {
if (!is_object($entity)) {
return;
}
$entityClass = ClassUtils::getClass($entity);
$entityManager = $this->managerRegistry->getManagerForClass($entityClass);
if (!$entityManager) {
return;
}
$entityIdentifier = $entityManager->getClassMetadata($entityClass)->getIdentifierValues($entity);
$isEntityExists = !empty($entityIdentifier);
}
// if entity exists and assign is not granted - replace field with disabled text field,
// otherwise - set default owner value
if ($isEntityExists) {
$this->replaceOwnerField($form);
} else {
$this->setPredefinedOwner($form);
}
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:34,代码来源:OwnerFormSubscriber.php
示例15: onLexikjwtauthenticationOnjwtcreated
public function onLexikjwtauthenticationOnjwtcreated(JWTCreatedEvent $event)
{
$em = $this->registry->getManager();
$data = $event->getData();
$data['wownewfield'] = 'muchcool';
$event->setData($data);
}
开发者ID:jschroed91,项目名称:symfony-oauth-example,代码行数:7,代码来源:JWTCreatedListener.php
示例16: testSubmit
public function testSubmit()
{
$choice = new \stdClass();
$choice->{$identifierPath = 'id'} = $id = 1;
$choice->{$labelPath = 'label'} = $label = 'label';
$this->resource->expects($this->once())->method('getModel')->will($this->returnValue($model = get_class($choice)));
$this->resource->expects($this->once())->method('getIdPropertyPath')->will($this->returnValue($identifierPath));
$this->resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPath));
$this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->identicalTo($model))->will($this->returnValue($documentManager = $this->createDocumentManagerMock()));
$documentManager->expects($this->once())->method('getRepository')->with($this->identicalTo($model))->will($this->returnValue($repository = $this->createRepositoryMock()));
$documentManager->expects($this->exactly(2))->method('getClassMetadata')->with($this->identicalTo($model))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
$classMetadata->expects($this->once())->method('getName')->will($this->returnValue($model));
$classMetadata->expects($this->once())->method('getIdentifierFieldNames')->will($this->returnValue([$identifier = $identifierPath]));
$classMetadata->expects($this->once())->method('getTypeOfField')->with($this->identicalTo($identifier))->will($this->returnValue('integer'));
$repository->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock($documentManager)));
$queryBuilder->expects($this->once())->method('getQuery')->will($this->returnValue($query = $this->createQueryMock()));
$query->expects($this->once())->method('execute')->will($this->returnValue($iterator = $this->createIteratorMock()));
$iterator->expects($this->once())->method('toArray')->will($this->returnValue([$choice]));
$form = $this->factory->create(ResourceChoiceType::class, null, ['resource' => $this->resource])->submit($id);
$this->assertSame($this->resource, $form->getConfig()->getOption('resource'));
$this->assertSame($identifierPath, $form->getConfig()->getOption('choice_value'));
$this->assertSame($labelPath, $form->getConfig()->getOption('choice_label'));
$this->assertSame('', $form->getConfig()->getOption('placeholder'));
$this->assertSame($choice, $form->getData());
$form->createView();
}
开发者ID:php-lug,项目名称:lug,代码行数:26,代码来源:ResourceChoiceTypeTest.php
示例17: testSubmit
public function testSubmit()
{
$choice = new \stdClass();
$choice->{$identifierPath = 'id'} = $id = 1;
$choice->{$labelPath = 'label'} = $label = 'label';
$this->resource->expects($this->once())->method('getModel')->will($this->returnValue($model = get_class($choice)));
$this->resource->expects($this->once())->method('getIdPropertyPath')->will($this->returnValue($identifierPath));
$this->resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPath));
$this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->identicalTo($model))->will($this->returnValue($entityManager = $this->createEntityManagerMock()));
$entityManager->expects($this->once())->method('getRepository')->with($this->identicalTo($model))->will($this->returnValue($repository = $this->createRepositoryMock()));
$entityManager->expects($this->exactly(3))->method('getClassMetadata')->with($this->identicalTo($model))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
$classMetadata->expects($this->once())->method('getName')->will($this->returnValue($model));
$classMetadata->expects($this->once())->method('getIdentifierFieldNames')->will($this->returnValue([$identifier = $identifierPath]));
$classMetadata->expects($this->exactly(2))->method('getTypeOfField')->with($this->identicalTo($identifier))->will($this->returnValue('integer'));
$repository->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock($entityManager)));
$queryBuilder->expects($this->exactly(2))->method('getQuery')->will($this->returnValue($query = $this->createQueryMock()));
$query->expects($this->once())->method('execute')->will($this->returnValue($choices = [$choice]));
$queryBuilder->expects($this->once())->method('getRootAliases')->will($this->returnValue([$rootAlias = 'root_alias']));
$queryBuilder->expects($this->once())->method('expr')->will($this->returnValue($expr = $this->createExprMock()));
$queryBuilder->expects($this->once())->method('getEntityManager')->will($this->returnValue($entityManager));
$queryBuilder->expects($this->once())->method('getRootEntities')->will($this->returnValue([$model]));
$expr->expects($this->once())->method('in')->with($this->identicalTo($rootAlias . '.' . $identifier), $this->identicalTo(':' . ($parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_' . $identifier)))->will($this->returnValue($where = 'where'));
$queryBuilder->expects($this->once())->method('andWhere')->with($this->identicalTo($where))->will($this->returnSelf());
$query->expects($this->once())->method('setParameter')->with($this->identicalTo($parameter), $this->identicalTo([(string) $id]), $this->identicalTo(Connection::PARAM_INT_ARRAY))->will($this->returnSelf());
$query->expects($this->once())->method('getResult')->will($this->returnValue([$choice]));
$entityManager->expects($this->exactly(2))->method('contains')->with($this->identicalTo($choice))->will($this->returnValue(true));
$classMetadata->expects($this->exactly(2))->method('getIdentifierValues')->with($this->identicalTo($choice))->will($this->returnValue([$id]));
$form = $this->factory->create(ResourceChoiceType::class, null, ['resource' => $this->resource])->submit($id);
$this->assertSame($this->resource, $form->getConfig()->getOption('resource'));
$this->assertSame($identifierPath, $form->getConfig()->getOption('choice_value'));
$this->assertSame($labelPath, $form->getConfig()->getOption('choice_label'));
$this->assertSame('', $form->getConfig()->getOption('placeholder'));
$this->assertSame($choice, $form->getData());
$form->createView();
}
开发者ID:blazarecki,项目名称:lug,代码行数:35,代码来源:ResourceChoiceTypeTest.php
示例18: process
/**
* {@inheritDoc}
*/
public function process(DatagridInterface $grid, array $config)
{
$this->datagrid = $grid;
if (isset($config['query'])) {
$queryConfig = array_intersect_key($config, array_flip(['query']));
$converter = new YamlConverter();
$this->qb = $converter->parse($queryConfig, $this->doctrine);
} elseif (isset($config['entity']) && isset($config['repository_method'])) {
$entity = $config['entity'];
$method = $config['repository_method'];
$repository = $this->doctrine->getRepository($entity);
if (method_exists($repository, $method)) {
$qb = $repository->{$method}();
if ($qb instanceof QueryBuilder) {
$this->qb = $qb;
} else {
throw new DatasourceException(sprintf('%s::%s() must return an instance of Doctrine\\ORM\\QueryBuilder, %s given', get_class($repository), $method, is_object($qb) ? get_class($qb) : gettype($qb)));
}
} else {
throw new DatasourceException(sprintf('%s has no method %s', get_class($repository), $method));
}
} else {
throw new DatasourceException(get_class($this) . ' expects to be configured with query or repository method');
}
if (isset($config['hints'])) {
$this->queryHints = $config['hints'];
}
$grid->setDatasource(clone $this);
}
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:OrmDatasource.php
示例19: setUp
protected function setUp()
{
$encoder = new TokenEncoder($this->secret);
$this->doctrine = $this->createDoctrineMock();
$this->doctrine->expects($this->any())->method('getManager')->willReturn($this->getMockForAbstractClass(EntityManagerInterface::class));
$this->manager = new TokenManager($encoder, $this->doctrine);
}
开发者ID:treehouselabs,项目名称:keystone-bundle,代码行数:7,代码来源:TokenManagerTest.php
示例20: prepareDatabase
private function prepareDatabase()
{
/** @var EntityManager $em */
$em = $this->registry->getManager();
$tool = new SchemaTool($em);
$tool->createSchema($em->getMetadataFactory()->getAllMetadata());
}
开发者ID:karol-wojcik,项目名称:serializer,代码行数:7,代码来源:IntegrationTest.php
注:本文中的Doctrine\Common\Persistence\ManagerRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论