FilterFormat.php

Same filename in this branch
  1. 9 core/modules/filter/src/Entity/FilterFormat.php
  2. 9 core/modules/filter/src/Plugin/DataType/FilterFormat.php
  3. 9 core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
Same filename in other branches
  1. 8.9.x core/modules/filter/src/Entity/FilterFormat.php
  2. 8.9.x core/modules/filter/src/Plugin/DataType/FilterFormat.php
  3. 8.9.x core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
  4. 8.9.x core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php
  5. 10 core/modules/filter/src/Entity/FilterFormat.php
  6. 10 core/modules/filter/src/Plugin/DataType/FilterFormat.php
  7. 10 core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
  8. 10 core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php
  9. 11.x core/modules/filter/src/Entity/FilterFormat.php
  10. 11.x core/modules/filter/src/Plugin/DataType/FilterFormat.php
  11. 11.x core/modules/filter/src/Plugin/migrate/source/d6/FilterFormat.php
  12. 11.x core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php

Namespace

Drupal\filter\Plugin\migrate\source\d7

File

core/modules/filter/src/Plugin/migrate/source/d7/FilterFormat.php

View source
<?php

namespace Drupal\filter\Plugin\migrate\source\d7;

use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;

/**
 * Drupal 7 filter source from database.
 *
 * For available configuration keys, refer to the parent classes.
 *
 * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
 * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
 *
 * @MigrateSource(
 *   id = "d7_filter_format",
 *   source_module = "filter"
 * )
 */
class FilterFormat extends DrupalSqlBase {
    
    /**
     * {@inheritdoc}
     */
    public function query() {
        return $this->select('filter_format', 'f')
            ->fields('f');
    }
    
    /**
     * {@inheritdoc}
     */
    public function fields() {
        return [
            'format' => $this->t('Format ID.'),
            'name' => $this->t('The name of the format.'),
            'cache' => $this->t('Whether the format is cacheable.'),
            'status' => $this->t('The status of the format'),
            'weight' => $this->t('The weight of the format'),
            'filters' => $this->t('The filters configured for the format.'),
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function prepareRow(Row $row) {
        // Find filters for this format.
        $filters = $this->select('filter', 'f')
            ->fields('f')
            ->condition('format', $row->getSourceProperty('format'))
            ->condition('status', 1)
            ->execute()
            ->fetchAllAssoc('name');
        foreach ($filters as $id => $filter) {
            $filters[$id]['settings'] = unserialize($filter['settings']);
        }
        $row->setSourceProperty('filters', $filters);
        return parent::prepareRow($row);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getIds() {
        $ids['format']['type'] = 'string';
        return $ids;
    }

}

Classes

Title Deprecated Summary
FilterFormat Drupal 7 filter source from database.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.