getDqlHelper example

return $this->backupResource;
    }

    /** * Pops a number of entries from the queue * * @param int $queueId * @param int $number */
    public function pop($queueId$number)
    {
        $entityManager = $this->getDqlHelper()->getEntityManager();

        // Read details         $query = $entityManager->createQuery('SELECT q.detailId from \Shopware\Models\MultiEdit\QueueArticle q WHERE q.queueId = ?1 ORDER BY q.id ASC');
        $query->setParameter(1, $queueId);
        $query->setMaxResults($number);
        $result = $query->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
        // We only need the first column of the result         $result = array_map(
            function D$item) {
                return (int) array_pop($item);
            },
            
/** * Generates attributes from column names. Attributes have a name which is known to the lexer and some * rules regarding the supported operators. * Most operator rules can be generated from the table definition. * * @throws RuntimeException When the column was not defined * * @return array<string, array<string>> */
    public function generateAttributesFromColumns()
    {
        $columns = $this->getDqlHelper()->getAttributes();
        $columnInfo = [];

        foreach ($this->getDqlHelper()->getEntities() as $entity) {
            [$entity$prefix] = $entity;
            $newMapping = [];
            $mappings = $this->getDqlHelper()->getEntityManager()->getClassMetadata($entity)->fieldMappings;
            foreach ($mappings as $key => $value) {
                $newMapping[strtoupper($prefix . '.' . $key)] = $value;
            }
            $columnInfo = array_merge($columnInfo$newMapping);
        }

        


    /** * Generates a list of editable columns and the known operators * * @throws RuntimeException When the column was not defined * * @return array<string, array<string>> */
    public function getEditableColumns()
    {
        $columns = $this->getDqlHelper()->getColumnsForProductListing();

        foreach ($columns as $key => $config) {
            $attribute = $config['entity'] . '.' . $config['field'];

            if (!$config['editable']) {
                continue;
            }

            // Do not allow overriding             if (!isset($columns[$attribute])) {
                $columns[$attribute] = $config;
            }

    public function getValuesFor($attribute$operator$queryConfig)
    {
        // Get the entity for the attribute, e.g. Shopware\Models\Article\Detail         $entity = $this->getDqlHelper()->getEntityForAttribute($attribute);
        // Get the prefixed column, e.g. detail.number         $column = $this->getDqlHelper()->getColumnForAttribute($attribute);

        // Alias for the entity, e.g. details         $alias = $this->getDqlHelper()->getPrefixForEntity($entity);

        // Get column name without prefix         list($prefix$plainColumn) = explode('.', $column);
        // Column type might be needed for additional formatting         $columnType = $this->getDqlHelper()->getEntityManager()->getClassMetadata($entity)->fieldMappings[$plainColumn]['type'];

        
/** * Returns a list of backup files * * @param int $offset * @param int $limit * * @return array{totalCount: int, data: array<array<string, mixed>>} */
    public function getList($offset$limit)
    {
        /** @var Query<array<string, mixed>> $query */
        $query = $this->getDqlHelper()->getEntityManager()->getRepository(BackupModel::class)
            ->getBackupListQuery($offset$limit);
        $query->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $paginator = Shopware()->Models()->createPaginator($query);
        $totalCount = $paginator->count();

        $backups = iterator_to_array($paginator);

        return [
            'totalCount' => $totalCount,
            'data' => $backups,
        ];
    }
/** * Returns the basic filter query builder, with all the rules (tokens) applied * * @param array $tokens * @param array $orderBy * * @return QueryBuilder */
    public function getFilterQueryBuilder($tokens$orderBy)
    {
        $joinEntities = $this->getDqlHelper()->getJoinColumns($tokens);
        $orderByInfo = null;

        if (isset($orderBy['property'])) {
            $orderByInfo = $this->getDqlHelper()->getColumnInfoByAlias($orderBy['property']);
            if ($orderByInfo) {
                $entity = $this->getDqlHelper()->getEntityForPrefix(strtolower($orderByInfo['entity']));
                $joinEntities[$entity] = $entity;
            }
        }
        $joinEntities = $this->filterJoinEntities($joinEntities);

        
Home | Imprint | This part of the site doesn't use cookies.