本文整理汇总了PHP中Seitenbau\Registry::getEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::getEntityManager方法的具体用法?PHP Registry::getEntityManager怎么用?PHP Registry::getEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seitenbau\Registry
的用法示例。
在下文中一共展示了Registry::getEntityManager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllByWebsiteId
/**
* @param string $websiteId
* @return array[] \Orm\Entity\Group
*/
public function getAllByWebsiteId($websiteId)
{
// Website vorhanden?
$website = $this->getService('Website')->getById($websiteId);
$groups = $this->getService()->getAllByWebsiteId($website->getId());
if (is_array($groups) && count($groups) > 0) {
$entityManager = \Seitenbau\Registry::getEntityManager();
foreach ($groups as $group) {
if (is_array($group->getUsers())) {
$usersOfGroup = $group->getUsers();
} else {
$usersOfGroup = json_decode($group->getUsers());
}
if (is_array($usersOfGroup) && count($usersOfGroup) > 0) {
$userService = $this->getService('User');
$userOrms = array();
foreach ($usersOfGroup as $userId) {
if ($userId instanceof \Orm\Entity\User) {
$userId = $userId->getId();
}
$user = $userService->getById($userId);
$groupsOfUser = $this->getService()->getAllByUserId($user->getId());
$user->setGroups($groupsOfUser);
$userOrms[] = $user;
$entityManager->detach($user);
}
$group->setUsers($userOrms);
} else {
$group->setUsers(array());
}
$entityManager->detach($group);
}
}
return $groups;
}
示例2: setEntityManagerShouldSetEntityManager
/**
* @test
* @group library
*/
public function setEntityManagerShouldSetEntityManager()
{
$this->assertInstanceOf('Doctrine\\ORM\\EntityManager', Registry::getEntityManager());
}
示例3: getDoctrineMigrationConfig
protected function getDoctrineMigrationConfig()
{
$config = Registry::getConfig();
// Doctrine Migration
$entityManager = Registry::getEntityManager();
$configuration = new \Doctrine\DBAL\Migrations\Configuration\Configuration($entityManager->getConnection());
$configuration->setName($config->migration->doctrine->name);
$configuration->setMigrationsNamespace($config->migration->doctrine->migrations_namespace);
$configuration->setMigrationsTableName($config->migration->doctrine->table_name);
$configuration->setMigrationsDirectory($config->migration->doctrine->migrations_directory);
$configuration->registerMigrationsFromDirectory($configuration->getMigrationsDirectory());
return $configuration;
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$entityManager = Registry::getEntityManager();
}
示例5: initEntityManager
/**
* init the doctrine entity manager form registry
*/
protected function initEntityManager()
{
$this->setEntityManager(Registry::getEntityManager());
}
示例6: getEntityManager
/**
* @return \Doctrine\ORM\EntityManager
*/
protected function getEntityManager()
{
return Registry::getEntityManager();
}