getTableName example

/** * Remove the node migrate map table. * * @param string $type * The type of node migration, 'complete' or 'classic'. * @param string $version * The source database version. * * @throws \Exception */
  protected function removeNodeMigrateMapTable($type$version) {
    $name = $this->getTableName($type$version);
    \Drupal::database()->schema()->dropTable($name);
  }

  /** * Gets the migrate_map table name. * * @param string $type * The type of node migration, 'complete' or 'classic'. * @param string $version * The source database version. * * @return string * The migrate_map table name. */
$key = $entityShort . ucfirst($name);
                $mapping = $metadata->getFieldMapping($name);
                $result[$key] = [
                    'entity' => $entityShort,
                    'field' => $name,
                    'editable' => substr($name, -2) !== 'Id' && $name !== 'id' && substr($name, -2) !== 'ID' && $entity !== Tax::class && $entity !== Supplier::class,
                    'type' => $config['type'],
                    'precision' => \array_key_exists('precision', $config) ? $config['precision'] : 10,
                    'scale' => \array_key_exists('scale', $config) ? $config['scale'] : 3,
                    'nullable' => \array_key_exists('nullable', $config) ? (bool) $config['nullable'] : false,
                    'columnName' => $mapping['columnName'],
                    'table' => $metadata->getTableName(),
                    'alias' => $alias,
                    'show' => \in_array($alias$shownColumns),
                    'position' => \array_key_exists($alias$columnPositions) ? $columnPositions[$alias] : -1,
                ];

                $result[$key]['allowInGrid'] = $this->showColumnInGrid($result[$key]);
            }
        }

        $alias = 'Price_price';
        $result['PricePrice'] = [
            

    }

    /** * @param ConfigurationStruct[] $columns */
    private function translateColumns(array $columns): void
    {
        $snippets = $this->container->get('snippets')->getNamespace('backend/attribute_columns');

        foreach ($columns as $column) {
            $key = $column->getTableName() . '_' . $column->getColumnName() . '_';

            if ($snippet = $snippets->get($key . 'label')) {
                $column->setLabel($snippet);
            }
            if ($snippet = $snippets->get($key . 'supportText')) {
                $column->setSupportText($snippet);
            }
            if ($snippet = $snippets->get($key . 'helpText')) {
                $column->setHelpText($snippet);
            }

            
$config,
            $newColumnName,
            $unifiedType,
            $defaultValue
        );

        if (!$schemaChanged) {
            return;
        }

        $this->schemaOperator->changeColumn(
            $config->getTableName(),
            $originalColumnName,
            $newColumnName,
            $this->typeMapping->unifiedToSQL($unifiedType),
            $this->parseDefaultValue($unifiedType$defaultValue)
        );
    }

    /** * @param string|int|float|null $defaultValue * * @return string|int|float */
$associatedContacts[] = $fetchedContact;
            }
        }

        $collection = new ArrayCollection($associatedContacts);
        $logEntry->setRecipients($collection);
    }

    protected function getKnownRecipients(array $recipients): array
    {
        $qb = $this->entityManager->getConnection()->createQueryBuilder();
        $tableName = $this->entityManager->getClassMetadata(Contact::class)->getTableName();

        $qb->select('*')
            ->from($tableName)
            ->add('where', $qb->expr()->in('mail_address', ':recipients'))
            ->setParameter('recipients', $recipients, Connection::PARAM_STR_ARRAY);

        return $qb->execute()->fetchAll(PDO::FETCH_ASSOC);
    }

    protected function persistContact(Contact $contact): void
    {
        


    /** * @param array{data_class: class-string<ModelEntity>} $options * * @return void */
    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
return $result;
    }

    public function save(array $data, ?int $id = null): int
    {
        $this->validateFields($data);
        $data = $this->filterFields($data);
        $data = $this->quoteFields($data);

        $data['updated_at'] = date('Y-m-d H:i:s');
        if ($id) {
            $this->connection->update($this->type->getTableName()$data['id' => $id]);
        } else {
            $data['created_at'] = date('Y-m-d H:i:s');
            $this->connection->insert($this->type->getTableName()$data);
            $id = (int) $this->connection->lastInsertId();
        }

        return $id;
    }

    public function delete(int $id): bool
    {
        
public function executeInserts()
    {
        if ($this->queuedInserts) {
            return [];
        }

        $postInsertIds  = [];
        $idGenerator    = $this->class->idGenerator;
        $isPostInsertId = $idGenerator->isPostInsertGenerator();

        $stmt      = $this->conn->prepare($this->getInsertSQL());
        $tableName = $this->class->getTableName();

        foreach ($this->queuedInserts as $entity) {
            $insertData = $this->prepareInsertData($entity);

            if (isset($insertData[$tableName])) {
                $paramIndex = 1;

                foreach ($insertData[$tableName] as $column => $value) {
                    $stmt->bindValue($paramIndex++, $value$this->columnTypes[$column]);
                }
            }

            
$schema = clone $currentSchema;

        // Mark all content type to be deleted, hopefully they will be redefined in the next step         foreach ($schema->getTables() as $table) {
            if (strpos($table->getName(), 's_custom_') === 0) {
                $schema->dropTable($table->getName());
            }
        }

        // Create all tables         foreach ($types as $type) {
            $myTable = $schema->createTable($type->getTableName());
            $myTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
            $myTable->setPrimaryKey(['id']);

            /** @var Field $field */
            foreach ($type->getFields() as $field) {
                $myTable->addColumn($field->getName()$field->getType()::getDbalType()['notnull' => $field->isRequired()]);
            }

            $myTable->addColumn('created_at', 'datetime', []);
            $myTable->addColumn('updated_at', 'datetime', []);
        }

        
SQL
        );

        $fieldsPerEntity = $this->groupFieldsPerEntity($customMediaFields);

        $statements = [];
        foreach ($fieldsPerEntity as $entity => $fields) {
            $table = $this->getTableName((string) $entity);

            foreach ($fields as $field) {
                $statements[] = "SELECT JSON_UNQUOTE(JSON_EXTRACT({$table}.custom_fields, '$.{$field}')) as media_id FROM `{$table}` WHERE JSON_UNQUOTE(JSON_EXTRACT(`{$table}`.custom_fields, '$.{$field}')) IN (?)";
            }
        }

        if (\count($statements) === 0) {
            return;
        }

        foreach ($statements as $statement) {
            


        $allMetaData = $this->getMetadataFactory()->getAllMetadata();
        $proxyFactory = $this->getProxyFactory();

        $attributeMetaData = [];
        foreach ($allMetaData as $metaData) {
            if (!$metaData instanceof ClassMetadata) {
                continue;
            }

            $tableName = $metaData->getTableName();
            if (!str_contains($tableName, '_attributes')) {
                continue;
            }
            if (!empty($tableNames) && !\in_array($tableName$tableNames, true)) {
                continue;
            }
            $attributeMetaData[] = $metaData;
        }
        $proxyFactory->generateProxyClasses($attributeMetaData);
    }

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