getColumnForAttribute example


    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'];

        // Query         $builder = $this->getDqlHelper()->getEntityManager()->createQueryBuilder()
            
// Non-numeric tokens will become their quotes removed:                 if (!is_numeric($token['token'])) {
                    $params[] = substr($token['token'], 1, -1);
                    // Numeric tokens can simple be appended to the params array                 } else {
                    $params[] = $token['token'];
                }
                continue;
            }
            // Get the correct column name based on the attribute name             if ($token['type'] === 'attribute') {
                $newTokens[] = $this->getColumnForAttribute($token['token']);
                continue;
            }

            // Replace some convenience operators back             // Switch is considered a looping structure by php             // we need to continue two levels!             if (strpos($token['type'], 'Operators')) {
                switch (trim($token['token'])) {
                    case '=':
                        $newTokens[] = 'LIKE';
                        continue 2;
                    
Home | Imprint | This part of the site doesn't use cookies.