本文整理汇总了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP ProxyQueryInterface::getQuery方法的具体用法?PHP ProxyQueryInterface::getQuery怎么用?PHP ProxyQueryInterface::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Datagrid\ProxyQueryInterface
的用法示例。
在下文中一共展示了ProxyQueryInterface::getQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: batchDelete
/**
* Deletes a set of $class identified by the provided $idx array
*
* @param string $class
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryProxy
*
* @return void
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
try {
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$this->delete($object[0]);
}
} catch (\PDOException $e) {
throw new ModelManagerException('', 0, $e);
}
}
示例2: batchDelete
/**
* {@inheritdoc}
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
$queryProxy->select('DISTINCT ' . $queryProxy->getRootAlias());
try {
$entityManager = $this->getEntityManager($class);
$i = 0;
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$entityManager->remove($object[0]);
if (++$i % 20 == 0) {
$entityManager->flush();
$entityManager->clear();
}
}
$entityManager->flush();
$entityManager->clear();
} catch (\PDOException $e) {
throw new ModelManagerException('', 0, $e);
} catch (DBALException $e) {
throw new ModelManagerException('', 0, $e);
}
}
示例3: batchDelete
/**
* Deletes a set of $class identified by the provided $idx array
*
* @param string $class
* @param array $idx
* @return void
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
$i = 0;
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$this->entityManager->remove($object[0]);
if ((++$i % 20) == 0) {
$this->entityManager->flush();
$this->entityManager->clear();
}
}
$this->entityManager->flush();
$this->entityManager->clear();
}
示例4: batchDelete
/**
* {@inheritdoc}
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$this->delete($object);
}
}
示例5: batchDelete
/**
* {@inheritdoc}
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
/** @var Query $queryBuilder */
$queryBuilder = $queryProxy->getQuery();
$documentManager = $this->getDocumentManager($class);
$i = 0;
foreach ($queryBuilder->execute() as $object) {
$documentManager->remove($object);
if (++$i % 20 == 0) {
$documentManager->flush();
$documentManager->clear();
}
}
$documentManager->flush();
$documentManager->clear();
}
示例6: batchDelete
/**
* Deletes a set of $class identified by the provided $idx array
*
* @param $class
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryProxy
* @return void
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
try {
$i = 0;
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$this->documentManager->remove($object[0]);
if (++$i % 20 == 0) {
$this->documentManager->flush();
$this->documentManager->clear();
}
}
$this->documentManager->flush();
$this->documentManager->clear();
} catch (\Exception $e) {
throw new ModelManagerException('', 0, $e);
}
}
示例7: batchDelete
/**
* @param string $class
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryProxy
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
if (count($queryProxy->getQuery()->getMap()) == 0) {
$queryProxy->deleteAll();
} else {
$queryProxy->delete();
}
}
示例8: preBatchAction
public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements)
{
if ($actionName == 'delete') {
try {
$test = array();
foreach ($query->getQuery()->iterate() as $pos => $object) {
$url = $object[0]->getUrl();
if (file_exists('/var/lib/mpd/' . $url) && in_array($object[0]->getId(), $idx)) {
chmod('/var/lib/mpd/' . $url, 0777);
if (!unlink('/var/lib/mpd/' . $url)) {
die('can\'t unlink');
}
}
}
} catch (\PDOException $e) {
throw new ModelManagerException('', 0, $e);
}
}
}
示例9: batchActionDownload
/**
* Execute a batch download
*
* @param ProxyQueryInterface $query
*
* @return RedirectResponse
*/
public function batchActionDownload(ProxyQueryInterface $queryProxy)
{
$flashType = 'success';
$dumper = new Dumper();
$dumper->setIndentation(4);
$response = new StreamedResponse(function () use($queryProxy, &$flashType, $dumper) {
try {
/**
* @var TransUnit $transUnit
*/
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
foreach ($object as $transUnit) {
$chunkPrefix = $transUnit->getDomain() . '__' . $transUnit->getKey() . '__' . $transUnit->getId() . '__';
$chunk = array();
/** @var TranslationInterface $translation */
foreach ($transUnit->getTranslations() as $translation) {
$chunk[$chunkPrefix . $translation->getLocale()] = $translation->getContent();
}
echo $dumper->dump($chunk, 2);
flush();
}
}
} catch (\PDOException $e) {
$flashType = 'error';
flush();
} catch (DBALException $e) {
$flashType = 'error';
flush();
}
});
$this->addFlash('sonata_flash_' . $flashType, 'translations.flash_batch_download_' . $flashType);
$response->headers->set('Content-Type', 'text/x-yaml');
$response->headers->set('Cache-Control', '');
$response->headers->set('Transfer-Encoding', 'chunked');
$response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s'));
$contentDisposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'translations.yml');
$response->headers->set('Content-Disposition', $contentDisposition);
return $response;
}