本文整理汇总了PHP中APY\DataGridBundle\Grid\Source\Entity::initQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::initQueryBuilder方法的具体用法?PHP Entity::initQueryBuilder怎么用?PHP Entity::initQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APY\DataGridBundle\Grid\Source\Entity
的用法示例。
在下文中一共展示了Entity::initQueryBuilder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: typeAction
/**
* Index view of content by type
*
* @param int $type
* @return Response
*/
public function typeAction($type)
{
$contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
if (!$contentType) {
throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
}
$queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createValuedQueryBuilder('c');
$source = new Entity($this->getParameter('opifer_content.content_class'));
$source->initQueryBuilder($queryBuilder);
$tableAlias = $source->getTableAlias();
$source->manipulateQuery(function ($query) use($tableAlias, $contentType) {
$query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
});
$editAction = new RowAction('button.edit', 'opifer_content_contenteditor_design');
$editAction->setRouteParameters(['id', 'type' => 'content']);
//$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
//$deleteAction->setRouteParameters(['id']);
/* @var $grid \APY\DataGridBundle\Grid\Grid */
$grid = $this->get('grid');
$grid->setId('content')->setSource($source)->addRowAction($editAction);
//->addRowAction($deleteAction)
foreach ($contentType->getSchema()->getAttributes() as $attribute) {
$name = $attribute->getName();
$column = new TextColumn(['id' => $name, 'field' => 'attributes.' . $attribute->getName() . '.value', 'title' => $attribute->getDisplayName()]);
$column->manipulateRenderCell(function ($value, $row, $router) use($name) {
$value = $row->getEntity()->getAttributes()[$name];
return $value;
});
$grid->addColumn($column);
}
return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), ['content_type' => $contentType, 'grid' => $grid]);
}
示例2: getSource
/**
* {@inheritdoc}
*/
public function getSource()
{
$source = new Entity('CSBillInvoiceBundle:Invoice');
$repo = $this->entityManager->getRepository('CSBillInvoiceBundle:Invoice');
$queryBuilder = $repo->createQueryBuilder('i');
$queryBuilder->where('i.recurring = 0');
$source->initQueryBuilder($queryBuilder);
return $source;
}
示例3: getSource
/**
* {@inheritdoc}
*/
public function getSource()
{
$this->entityManager->getFilters()->disable('archivable');
$source = new Entity('CSBillInvoiceBundle:Invoice');
/** @var InvoiceRepository $repo */
$repo = $this->entityManager->getRepository('CSBillInvoiceBundle:Invoice');
$queryBuilder = $repo->createQueryBuilder('i');
$queryBuilder->where('i.archived is not null');
$source->initQueryBuilder($queryBuilder);
return $source;
}
示例4: getSource
/**
* {@inheritdoc}
*/
public function getSource()
{
$this->objectManager->getFilters()->disable('softdeleteable');
$source = new Entity('CSBillClientBundle:Client');
/** @var ClientRepository $repo */
$repo = $this->objectManager->getRepository('CSBillClientBundle:Client');
$queryBuilder = $repo->createQueryBuilder('c');
$queryBuilder->where('c.deletedAt is not null');
$source->initQueryBuilder($queryBuilder);
return $source;
}
示例5: lister_utilisateurAction
public function lister_utilisateurAction()
{
if (false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') && false === $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
throw new AccessDeniedException();
}
// Creates a simple grid based on your entity (ORM)
$source = new Entity('ROUtilisateurBundle:Utilisateur');
// Get a Grid instance
$grid = $this->get('grid');
//Récupération du repository utilisateur
$utilisateurRepository = $this->getDoctrine()->getManager()->getRepository('ROUtilisateurBundle:Utilisateur');
//Dire au dataGrid que la source sera différente du paramétrage onnataion de l'entité modéle
$utilisateurQueryBuilder = $utilisateurRepository->loadUserForGrid();
$source->initQueryBuilder($utilisateurQueryBuilder);
//Création de la colonne avec les roles concaténé
$rolesColumn = new TextColumn(array('id' => 'concatNomRole', 'title' => 'Rôles', 'filterable' => false, 'sortable' => false));
$grid->addColumn($rolesColumn);
// Attach the source to the grid
$grid->setSource($source);
//Création de la possiblité d'exporter le listing au format CSV
$grid->addExport(new CSVExport('CSV Export', 'Export utilisateur CSV'));
$grid->addExport(new ExcelExport('XLS Export', 'Export utilisateur XLS'));
//Message a afficher si la valeur de l'attribut est vide
$grid->setNoDataMessage(' - ');
//Message a afficher si le listing ne contient aucune ligne
$grid->setNoResultMessage('Aucun resultat trouvé');
//GESTION DES ACTION DE LA COLONNE DE DROITE
//Ajout de l'action d'ajout utilisateur
$rowDetailAction = new RowAction('', 'ro_utilisateur_detail', false, '_self', array('class' => 'btn btn-primary'), array('class' => 'glyphicon glyphicon-eye-open', 'title' => 'Détail utilisateur'));
$grid->addRowAction($rowDetailAction);
//Ajout de l'action de modification utilisateur
$rowUpdateAction = new RowAction('', 'ro_utilisateur_edit', false, '_self', array('class' => 'btn btn-success'), array('class' => 'glyphicon glyphicon-edit glyphicon-white', 'title' => 'Modifier utilisateur'));
$grid->addRowAction($rowUpdateAction);
//Ajout de l'action de suppression utilisateur
$rowDeleteAction = new RowAction('', 'ro_utilisateur_delete', true, '_self', array('class' => 'btn btn-danger'), array('class' => 'glyphicon glyphicon-trash glyphicon-white', 'title' => 'Supprimer utilisateur'));
//Message de confirmation de suppression
$rowDeleteAction->setConfirmMessage('Etes vous sur de vouloir supprimer cet utilisateur ?');
$grid->addRowAction($rowDeleteAction);
//GESTION DES MASS ACTION
//Mass action,traitement sur plusieur ligne en les cochant,ici on crée un bouton de suppresssion
$grid->addMassAction(new DeleteMassAction());
// Return the response of the grid to the template
return $grid->getGridResponse('ROUtilisateurBundle:utilisateur:lister_utilisateur.html.twig');
}
示例6: indexAction
/**
* Menu index
*
* @return Response
*/
public function indexAction()
{
$qb = $this->container->get('opifer.cms.menu_manager')->getRepository()->getNodesHierarchyQueryBuilder();
$source = new Entity('OpiferCmsBundle:Menu');
$source->initQueryBuilder($qb);
$editAction = new RowAction('edit', 'opifer_cms_menu_edit');
$editAction->setRouteParameters(['id']);
$deleteAction = new RowAction('delete', 'opifer_cms_menu_delete');
$deleteAction->setRouteParameters(['id']);
$grid = $this->get('grid');
$grid->setId('menus')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction);
$grid->getColumn('name')->setSafe(false)->setFilterable(false)->setSortable(false)->manipulateRenderCell(function ($value, $row, $router) {
$item = $row->getEntity();
$indentation = $item->getLvl() ? str_repeat(' ', $item->getLvl() * 4) : '';
if ($item instanceof MenuItem) {
$route = $router->generate('opifer_cms_menu_edit', ['id' => $item->getId()]);
$html = $indentation . '<a href="' . $route . '"><span class="text-muted">' . $item->getName() . '</span></a>';
} else {
$html = $indentation . '<span class="text-muted">' . $item->getName() . '</span>';
}
return $html;
});
return $grid->getGridResponse('OpiferCmsBundle:Backend/Menu:index.html.twig');
}