本文整理匯總了PHP中Doctrine\ORM\EntityManager::close方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManager::close方法的具體用法?PHP EntityManager::close怎麽用?PHP EntityManager::close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\EntityManager
的用法示例。
在下文中一共展示了EntityManager::close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tearDown
/**
* {@inheritDoc}
*/
protected function tearDown()
{
parent::tearDown();
if ($this->em instanceof \Doctrine\ORM\EntityManager) {
$this->em->close();
}
}
示例2: tearDown
/**
* {@inheritDoc}
*/
protected function tearDown()
{
parent::tearDown();
if (!is_null($this->em)) {
$this->em->close();
}
}
示例3: tearDown
/**
* {@inheritDoc}
*/
protected function tearDown()
{
parent::tearDown();
$this->em->close();
$this->em = null;
// avoid memory leaks
}
示例4: allBooks
public function allBooks()
{
try {
$book = $this->em->getRepository('BooksApiBookBundle:BooksEntity')->findAll();
} catch (\Exception $ex) {
$this->em->close();
throw new QueryException('003', 502);
}
return $book;
}
示例5: tearDown
/**
* {@inheritDoc}
*/
protected function tearDown()
{
parent::tearDown();
$this->em->close();
//cerrar emMod
/*$this->emMod = static::$kernel->getContainer()
->get('doctrine')
->getManager();
$this->emMod->close();*/
}
示例6: tearDownDoctrine
/**
* @after
*/
protected function tearDownDoctrine()
{
$this->doctrine = null;
if ($this->em) {
$this->em->close();
$this->em = null;
}
$this->loader = null;
$this->container = null;
}
示例7: close
/**
* close Doctrine Dbal and ORM connection and reset everything to default.
*/
public function close()
{
$this->Conn->close();
if (is_object($this->EntityManager) && method_exists($this->EntityManager, 'close')) {
$this->EntityManager->close();
}
if (function_exists('gc_collect_cycles')) {
gc_collect_cycles();
}
$this->Conn = '';
$this->EntityManager = '';
$this->table_prefix = '';
$this->table_siteid_prefix = '';
}
示例8: createBook
/**
* @param $title
* @param $price
* @param $description
* @throws QueryException
*/
public function createBook($title, $price, $description)
{
$book = new BooksEntity();
$book->setTitle($title);
$book->setPrice($price);
$book->setDescription($description);
try {
$this->em->persist($book);
$this->em->flush();
return true;
} catch (\Exception $ex) {
$this->em->close();
throw new QueryException('003', 502);
}
}
示例9: restartDoctrine
public function restartDoctrine()
{
$enabled_filters = array();
if (isset($this->entity_manager)) {
$filters = $this->entity_manager->getFilters();
foreach ($filters->getEnabledFilters() as $filter_name => $filter) {
$filter_class = get_class($filter);
$enabled_filters[$filter_name] = array($filter_class => $filter->__toString());
}
@$this->entity_manager->close();
unset($this->entity_manager);
}
$em = $this->getDoctrine();
foreach ($enabled_filters as $filter_name => $filter) {
foreach ($filter as $filter_class => $filter_params_string) {
$em->getConfiguration()->addFilter($filter_name, $filter_class);
$this_filter = $em->getFilters()->enable($filter_name);
$filter_params = @unserialize($filter_params_string);
if ($filter_params) {
foreach ($filter_params as $filter_param => $filter_value) {
if (isset($filter_value['value'])) {
$this_filter->setParameter($filter_param, $filter_value['value']);
}
}
}
}
}
}
示例10: tearDown
/**
* {@inheritDoc}
*/
protected function tearDown()
{
parent::tearDown();
$this->em->remove($this->user);
$this->em->close();
//unset($this->user); //
}
示例11: uninstall
/**
* @param \Venne\Module\IModule $module
*/
public function uninstall(IModule $module)
{
if (!$this->context->hasService('doctrine') || !$this->context->doctrine->createCheckConnection()) {
throw new \Exception('Database connection not found!');
}
$classes = $this->getClasses($module);
$metadata = array();
foreach ($classes as $class) {
$metadata[] = $this->entityManager->getClassMetadata($class);
}
$tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
$this->entityManager->getConnection()->beginTransaction();
try {
foreach ($classes as $class) {
$repository = $this->entityManager->getRepository($class);
foreach ($repository->findAll() as $entity) {
$repository->delete($entity);
}
}
$tool->dropSchema($metadata);
$this->entityManager->getConnection()->commit();
} catch (Exception $e) {
$this->entityManager->getConnection()->rollback();
$this->entityManager->close();
throw $e;
}
$this->cleanCache();
}
示例12: close
/**
* {@inheritdoc}
*/
public function close()
{
$evm = $this->getEventManager();
if ($evm->hasListeners(Events::preClose)) {
$evm->dispatchEvent(Events::preClose, new PreCloseEventArgs($this));
}
parent::close();
}
示例13: tearDownAfterClass
/**
* {@inheritDoc}
*
* @see PHPUnit_Framework_TestCase::tearDownAfterClass()
*
* @uses KernelTestCase::ensureKernelShutdown()
*/
public static function tearDownAfterClass()
{
parent::ensureKernelShutdown();
static::$em->close();
static::$em = null;
// avoid memory leaks
static::$repository->clear();
static::$repository = null;
}
示例14: dropEntityManager
/**
* Drop the entity manager
* @return void
*/
public function dropEntityManager()
{
if ($this->entityManager != null) {
$this->entityManager->getConnection()->close();
$this->entityManager->close();
}
unset($this->entityManager);
unset($this->fixtureReferenceRepo);
}
示例15: putWithdrawalAction
/**
* вывести деньги
*
* @ApiDoc(
* section="Billing API",
* input="Vifeed\PaymentBundle\Form\WithdrawalType",
* output={
* "class"="Vifeed\PaymentBundle\Entity\Withdrawal",
* "groups"={"default"}
* },
* resource=true,
* statusCodes={
* 201="Returned when successful",
* 400="Returned when something is wrong",
* 403="Returned when the user is not authorized to use this method"
* }
* )
*
* @return Response
*/
public function putWithdrawalAction()
{
$form = $this->createForm(new WithdrawalType());
$form->submit($this->get('request'));
if ($form->isValid()) {
/** @var Withdrawal $withdrawal */
$withdrawal = $form->getData();
if ($withdrawal->getWallet()->getUser() != $this->getUser()) {
throw new AccessDeniedHttpException('Можно вывести только на свой кошелёк');
}
if ($withdrawal->getAmount() > $this->getUser()->getBalance()) {
$form->get('amount')->addError(new FormError('Недостаточно денег на балансе'));
} else {
$userRepo = $this->em->getRepository('VifeedUserBundle:User');
$this->em->beginTransaction();
$this->em->lock($this->getUser(), LockMode::PESSIMISTIC_WRITE);
try {
$withdrawal->setUser($this->getUser())->setStatus(Withdrawal::STATUS_CREATED);
$this->em->persist($withdrawal);
$userRepo->updateBalance($this->getUser(), -$withdrawal->getAmount());
$this->em->flush();
$this->em->commit();
} catch (\Exception $e) {
$this->em->rollback();
$this->em->close();
throw $e;
}
$mailer = $this->get('vifeed.mailer');
$message = $mailer->renderMessage('VifeedPaymentBundle:Email:withdrawal.html.twig', ['withdrawal' => $withdrawal]);
$mailer->sendMessage('Запрос на вывод средств', $message, $this->container->getParameter('withdrawal.notification.email'));
$context = new SerializationContext();
$context->setGroups(array('default'));
$view = new View($withdrawal, 201);
$view->setSerializationContext($context);
}
}
if (!$form->isValid()) {
$view = new View($form, 400);
}
return $this->handleView($view);
}