Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getObjectManager protected #423

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/Model/BaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ public function __construct(
) {
}

/**
* @throws \RuntimeException
*/
public function getObjectManager(): ObjectManager
{
$manager = $this->registry->getManagerForClass($this->class);

if (null === $manager) {
throw new \RuntimeException(sprintf(
'Unable to find the mapping information for the class %s.'
.' Please check the `auto_mapping` option'
.' (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview)'
.' or add the bundle to the `mappings` section in the doctrine configuration.',
$this->class
));
}

return $manager;
}

public function getClass(): string
{
return $this->class;
Expand Down Expand Up @@ -138,4 +118,24 @@ protected function checkObject(object $object): void
));
}
}

/**
* @throws \RuntimeException
*/
protected function getObjectManager(): ObjectManager
{
$manager = $this->registry->getManagerForClass($this->class);

if (null === $manager) {
throw new \RuntimeException(sprintf(
'Unable to find the mapping information for the class %s.'
.' Please check the `auto_mapping` option'
.' (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview)'
.' or add the bundle to the `mappings` section in the doctrine configuration.',
$this->class
));
}

return $manager;
}
}
2 changes: 1 addition & 1 deletion tests/Entity/BaseEntityManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testExceptionOnNonMappedEntity(): void

$this->registry->expects(static::once())->method('getManagerForClass')->willReturn(null);

$this->manager->getObjectManager();
$this->manager->clear(); // To trigger a getObjectManager call
}

public function testGetRepository(): void
Expand Down