function BlockVariantTrait::getRegionAssignments

Same name and namespace in other branches
  1. 4.0.x src/Plugin/BlockVariantTrait.php \Drupal\ctools\Plugin\BlockVariantTrait::getRegionAssignments()

See also

\Drupal\ctools\Plugin\BlockVariantInterface::getRegionAssignments()

File

src/Plugin/BlockVariantTrait.php, line 101

Class

BlockVariantTrait
Provides methods for <a href="/api/ctools/src%21Plugin%21BlockVariantInterface.php/interface/BlockVariantInterface/8.x-3.x" title="Provides an interface for variant plugins that use block plugins." class="local">\Drupal\ctools\Plugin\BlockVariantInterface</a>.

Namespace

Drupal\ctools\Plugin

Code

public function getRegionAssignments() {
    // Build an array of the region names in the right order.
    $empty = array_fill_keys(array_keys($this->getRegionNames()), []);
    $full = $this->getBlockCollection()
        ->getAllByRegion();
    // Merge it with the actual values to maintain the ordering.
    return array_intersect_key(array_merge($empty, $full), $empty);
}