You are here

class TagadelicCloudTaxonomy in Tagadelic 8.3

Class TagadelicCloud.

@package Drupal\tagadelic

Hierarchy

Expanded class hierarchy of TagadelicCloudTaxonomy

1 string reference to 'TagadelicCloudTaxonomy'
tagadelic.services.yml in ./tagadelic.services.yml
tagadelic.services.yml
1 service uses TagadelicCloudTaxonomy
tagadelic.tagadelic_taxonomy in ./tagadelic.services.yml
Drupal\tagadelic\TagadelicCloudTaxonomy

File

src/TagadelicCloudTaxonomy.php, line 15

Namespace

Drupal\tagadelic
View source
class TagadelicCloudTaxonomy extends TagadelicCloudBase {

  /**
   * Drupal\Core\Config\ConfigFactory definition.
   *
   * @var Drupal\Core\Config\ConfigFactory
   */
  protected $config_factory;

  /**
   * Constructor.
   */
  public function __construct(ConfigFactory $config_factory) {
    $this->config_factory = $config_factory;
    parent::__construct();
  }

  /**
   * {@inheritdoc}
   */
  public function createTags(array $options = array()) {
    $config = \Drupal::config('tagadelic.settings');
    $vocabularies = $config
      ->get('tagadelic_vocabularies');
    $max_amount = 50;
    $query = db_select('taxonomy_index', 'i');
    $alias = $query
      ->leftjoin('taxonomy_term_field_data', 't', '%alias.tid = i.tid');
    $query
      ->addExpression('COUNT(i.nid)', 'count');
    $query
      ->addField($alias, 'tid');
    $query
      ->addField($alias, 'name');
    $query
      ->addField($alias, 'description__value');
    $query
      ->orderBy('count', 'DESC');

    // If no vocabularies have been configured use them all
    if (count($vocabularies)) {
      foreach ($vocabularies as $key => $value) {
        if ($key !== $value) {
          $query
            ->condition('t.vid', $key, '<>');
        }
      }
    }
    $query
      ->range(0, $max_amount)
      ->groupBy("t.tid")
      ->groupBy("t.name")
      ->groupBy("t.description__value");
    foreach ($query
      ->execute() as $item) {
      $tag = new TagadelicTag($item->tid, $item->name, $item->count);
      $this
        ->addTag($tag);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TagadelicCloudBase::$steps private property #Amount of steps to weight the cloud in. Defaults to 6. Means: 6 different sized tags.
TagadelicCloudBase::$tags protected property An array of TagadelicTag objects.
TagadelicCloudBase::addTag public function Add a TagadelicTag object to the tags array. Overrides TagadelicCloudInterface::addTag
TagadelicCloudBase::cb_sort_by_count private function
TagadelicCloudBase::cb_sort_by_name private function
TagadelicCloudBase::getTags public function Return an array of Tagadelic Tags. Overrides TagadelicCloudInterface::getTags
TagadelicCloudBase::recalculate protected function (Re)calculates the weights on the tags.
TagadelicCloudBase::resetTags private function
TagadelicCloudBase::sort protected function
TagadelicCloudTaxonomy::$config_factory protected property Drupal\Core\Config\ConfigFactory definition.
TagadelicCloudTaxonomy::createTags public function Overrides TagadelicCloudBase::createTags
TagadelicCloudTaxonomy::__construct public function Constructor. Overrides TagadelicCloudBase::__construct