isIdentifier example



    public function listAction()
    {
        /** @var CrudServiceInterface $crudService */
        $crudService = $this->get(CrudServiceInterface::class);
        $columns = $crudService->getList(
            $this->Request()->getParam('table')
        );

        $columns = array_filter($columnsfunction DConfigurationStruct $column) {
            return $column->isIdentifier() == false;
        });

        if ($this->Request()->has('columns')) {
            $whitelist = json_decode($this->Request()->getParam('columns', []), true);
            $columns = array_filter($columnsfunction DConfigurationStruct $column) use ($whitelist) {
                return \in_array($column->getColumnName()$whitelist);
            });
        }

        if (!$this->Request()->getParam('raw')) {
            $this->translateColumns($columns);
        }
')'
        );
    }

    /** * @throws ExpressionErrorException */
    public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
    {
        $arguments = $function->getArguments();
        foreach ($arguments as $token) {
            if (!($token->isString() || $token->isIdentifier())) {
                throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
            }
        }

        return $xpath->addCondition(sprintf(
            'ancestor-or-self::*[@lang][1][starts-with(concat('
            ."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
            .', %s)]',
            'lang',
            Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-')
        ));
    }


                    $result = new Node\NegationNode($result$argument);
                } else {
                    $arguments = [];
                    $next = null;

                    while (true) {
                        $stream->skipWhitespace();
                        $next = $stream->getNext();

                        if ($next->isIdentifier()
                            || $next->isString()
                            || $next->isNumber()
                            || $next->isDelimiter(['+', '-'])
                        ) {
                            $arguments[] = $next;
                        } elseif ($next->isDelimiter([')'])) {
                            break;
                        } else {
                            throw SyntaxErrorException::unexpectedToken('an argument', $next);
                        }
                    }

                    


    /** * Returns next identifier token. * * @throws SyntaxErrorException If next token is not an identifier */
    public function getNextIdentifier(): string
    {
        $next = $this->getNext();

        if (!$next->isIdentifier()) {
            throw SyntaxErrorException::unexpectedToken('identifier', $next);
        }

        return $next->getValue();
    }

    /** * Returns next identifier or null if star delimiter token is found. * * @throws SyntaxErrorException If next token is not an identifier or a star delimiter */
    

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $metaData = $this->entityManager->getClassMetadata($options['data_class']);

        $attributes = $this->attributeService->getList($metaData->getTableName());

        foreach ($attributes as $attribute) {
            if ($attribute->isIdentifier()) {
                continue;
            }

            $field = $metaData->getFieldForColumn($attribute->getColumnName());
            $builder->add($field);
        }

        // set default value for all attribute fields to prevent null override if a field isn't in the submit data         $builder->addEventListener(FormEvents::POST_SET_DATA, function DFormEvent $event) use ($attributes$metaData) {
            try {
                $form = $event->getForm();
                
$map = [
                    'txtshortdescription' => 'description',
                    'txtlangbeschreibung' => 'description_long',
                    'txtshippingtime' => 'shippingtime',
                    'txtArtikel' => 'name',
                    'txtzusatztxt' => 'additionaltext',
                    'metaTitle' => 'metaTitle',
                ];

                $attributes = Shopware()->Container()->get(CrudService::class)->getList('s_articles_attributes');
                foreach ($attributes as $attribute) {
                    if ($attribute->isIdentifier()) {
                        continue;
                    }
                    $columnName = $attribute->getColumnName();
                    $map[CrudServiceInterface::EXT_JS_PREFIX . $columnName] = $columnName;
                }
                break;
            case 'link':
                $map = ['linkname' => 'description'];
                break;
            case 'download':
                $map = ['downloadname' => 'description'];
                

    private function getAttributeMapping(): array
    {
        $attributes = $this->crudService->getList('s_articles_attributes');

        $properties = [];
        foreach ($attributes as $attribute) {
            $name = $attribute->getColumnName();
            $type = $attribute->getElasticSearchType();

            if ($attribute->isIdentifier()) {
                continue;
            }

            switch ($type['type']) {
                case 'keyword':
                    $type = $this->textMapping->getKeywordField();
                    $type['fields']['raw'] = $this->textMapping->getKeywordField();
                    break;

                case 'string':
                case 'text':
                    
return $this->translateNthChild($xpath$function, true, false);
    }

    /** * @throws ExpressionErrorException */
    public function translateContains(XPathExpr $xpath, FunctionNode $function): XPathExpr
    {
        $arguments = $function->getArguments();
        foreach ($arguments as $token) {
            if (!($token->isString() || $token->isIdentifier())) {
                throw new ExpressionErrorException('Expected a single string or identifier for :contains(), got '.implode(', ', $arguments));
            }
        }

        return $xpath->addCondition(sprintf(
            'contains(string(.), %s)',
            Translator::getXpathLiteral($arguments[0]->getValue())
        ));
    }

    /** * @throws ExpressionErrorException */
/** * Helper function which returns the sql query for the seo products. * Used in multiple locations * * @return string */
    public function getSeoArticleQuery()
    {
        $attributesList = Shopware()->Container()->get(CrudServiceInterface::class)->getList('s_articles_attributes');
        $attributes = [];
        foreach ($attributesList as $attribute) {
            if ($attribute->isIdentifier()) {
                continue;
            }
            $attributes[] = 'at.' . $attribute->getColumnName();
        }

        return ' SELECT a.*, d.ordernumber, d.suppliernumber, s.name AS supplier, a.datum AS date, d.releasedate, a.changetime AS changed, ct.objectdata, ctf.objectdata AS objectdataFallback, ' . implode(',', $attributes) . " FROM s_articles a INNER JOIN s_articles_categories_ro ac ON ac.articleID = a.id AND ac.categoryID = ? INNER JOIN s_categories c ON c.id = ac.categoryID AND c.active = 1 JOIN s_articles_details d ON d.id = a.main_detail_id LEFT JOIN s_articles_attributes at ON at.articledetailsID=d.id LEFT JOIN s_core_translations ct ON ct.objectkey=a.id AND ct.objectlanguage=? AND ct.objecttype='article' LEFT JOIN s_core_translations ctf ON ctf.objectkey=a.id AND ctf.objectlanguage=? AND ctf.objecttype='article' LEFT JOIN s_articles_supplier s ON s.id=a.supplierID WHERE a.active=1 AND a.changetime > ? GROUP BY a.id ORDER BY a.changetime, a.id ";
Home | Imprint | This part of the site doesn't use cookies.