Get sorted listed of supported block definitions.

@return array
An associative array of supported block definitions.
557846
protected function getBlockDefinitions() {
    $definitions = $this->blockManager->getSortedDefinitions();
    $block_definitions = [];
    foreach ($definitions as $plugin_id => $definition) {
      // Context aware plugins are not currently supported.
      // Core and component plugins can be context-aware
      // https://www.drupal.org/node/1938688
      // @see \Drupal\ctools\Plugin\Block\EntityView
      if (isset($definition['context'])) {
        continue;
      }

      $block_definitions[$plugin_id] = $definition;
    }
    return $block_definitions;
  }
875715
protected function getExtensions()
    {
        if (null === $this->sorted) {
            ksort($this->extensions);
            $this->sorted = !empty($this->extensions)
                ? call_user_func_array('array_merge', $this->extensions)
                : [];
        }

        return $this->sorted;
    }
213731
public function sortBlocksByDirective($blocks, $sort)
    {
        array_walk($blocks, function ($block) use ($sort) {
            $block->setSort(array_search($block->getId(), $sort));
        });

        return $blocks;
    }
1117000
public function get_addable_blocks() {
        $this->check_is_loaded();

        if (!is_null($this->addableblocks)) {
            return $this->addableblocks;
        }

        // Lazy load.
        $this->addableblocks = array();

        $allblocks = blocks_get_record();
        if (empty($allblocks)) {
            return $this->addableblocks;
        }

        $unaddableblocks = self::get_undeletable_block_types();
        $requiredbythemeblocks = $this->get_required_by_theme_block_types();
        $pageformat = $this->page->pagetype;
        foreach($allblocks as $block) {
            if (!$bi = block_instance($block->name)) {
                continue;
            }
            if ($block->visible && !in_array($block->name, $unaddableblocks) &&
                    !in_array($block->name, $requiredbythemeblocks) &&
                    ($bi->instance_allow_multiple() || !$this->is_block_present($block->name)) &&
                    blocks_name_allowed_in_format($block->name, $pageformat) &&
                    $bi->user_can_addto($this->page)) {
                $block->title = $bi->get_title();
                $this->addableblocks[$block->name] = $block;
            }
        }

        core_collator::asort_objects_by_property($this->addableblocks, 'title');
        return $this->addableblocks;
    }
1333266
protected function magic_get_blocks() {
        global $CFG;
        if (is_null($this->_blocks)) {
            if (!empty($CFG->blockmanagerclass)) {
                if (!empty($CFG->blockmanagerclassfile)) {
                    require_once($CFG->blockmanagerclassfile);
                }
                $classname = $CFG->blockmanagerclass;
            } else {
                $classname = 'block_manager';
            }
            $this->_blocks = new $classname($this);
        }
        return $this->_blocks;
    }
1359706
public function getBlockPath()
    {
        if ($this->getPackageID() > 0) {
            $pkgHandle = $this->getPackageHandle();
            $dirp = (is_dir(DIR_PACKAGES . '/' . $pkgHandle)) ? DIR_PACKAGES : DIR_PACKAGES_CORE;
            $dir = $dirp . '/' . $pkgHandle . '/' . DIRNAME_BLOCKS . '/' . $this->getBlockTypeHandle();
        } else {
            if (is_dir(DIR_FILES_BLOCK_TYPES . '/' . $this->getBlockTypeHandle())) {
                $dir = DIR_FILES_BLOCK_TYPES . '/' . $this->getBlockTypeHandle();
            } else {
                $dir = DIR_FILES_BLOCK_TYPES_CORE . '/' . $this->getBlockTypeHandle();
            }
        }

        return $dir;
    }
131570
public function getSupportedRights() {
        $models = $this->getInner();
        $first = array_pop($models);
        $supported = $first->getSupportedRights();
        
        while (!empty($models)) {
            $model = array_pop($models);
            $supported = array_intersect($supported, $model->getSupportedRights());
        }
        
        return array_values($supported);
    }
756965
public function getUseDeclarations() {
    $declarations = [];
    /** @var \Pharborist\Namespaces\UseDeclarationBlockNode[] $use_blocks */
    $use_blocks = $this->children(Filter::isInstanceOf('\Pharborist\Namespaces\UseDeclarationBlockNode'));
    foreach ($use_blocks as $use_block) {
      foreach ($use_block->getDeclarationStatements() as $use_statement) {
        $declarations = array_merge($declarations, $use_statement->getDeclarations()->toArray());
      }
    }
    return new NodeCollection($declarations, FALSE);
  }
214341
public function getSortedQuestions()
    {
        $criteria = Criteria::create();
        $criteria->orderBy(array('rank' => 'ASC'));

        return $this->getQuestions()->matching($criteria);
    }
1137406
public function getBlocks()
    {
        if ($this->blocks !== null) {
            return $this->blocks;
        }
        $this->findBrocks();
        return $this->blocks;
    }
625182
public function get_supported_orders(\context $context) {
        $orders = parent::get_supported_orders($context);

        // If not within a course, no other kind of sorting supported.
        $coursecontext = $context->get_course_context(false);
        if ($coursecontext) {
            // Within a course or activity/block, support sort by location.
            $orders['location'] = get_string('order_location', 'search',
                    $context->get_context_name());
        }

        return $orders;
    }
343279
public static function getSupportedProtocols()
    {
        $supportedProtocols = array();
        $supportedProtocols[CAS_VERSION_1_0] = 'CAS 1.0';
        $supportedProtocols[CAS_VERSION_2_0] = 'CAS 2.0';
        $supportedProtocols[CAS_VERSION_3_0] = 'CAS 3.0';
        $supportedProtocols[SAML_VERSION_1_1] = 'SAML 1.1';

        return $supportedProtocols;
    }
178179
private function availableTreeBlocks(): Collection
    {
        return $this->module_service->findByInterface(ModuleBlockInterface::class, false, true)
            ->filter(static function (ModuleBlockInterface $block): bool {
                return $block->isTreeBlock();
            })
            ->mapWithKeys(static function (ModuleInterface $block): array {
                return [$block->name() => $block];
            });
    }
1339654
public function sortBlocks(array $blocks)
    {
        // Determine hierarchy of ownership first
        $hierarchy = array();
        foreach ($blocks as $block) {
            if ($block instanceof BlockOwnerInterface) {
                $key = ($block->getParent()) ? array_search($block->getParent()->getId(), $hierarchy) : false;
                $pos = ($key) ? $key-1 : count($hierarchy)+1;
                $hierarchy[$pos] = $block->getId();
            }
        }
        $hierarchy = array_flip($hierarchy); // Flip it for easier lookup by parentId as key.

        usort($blocks, function ($a, $b) use ($hierarchy) {
            if ($a->getOwner() === null || $b->getOwner() === null) {
                return 0;
            }

            // when blocks sort positions are equal and they have different
            // owners apply inherited sorting
            if ($a->getSort() === $b->getSort() && $a->getOwner()->getId() != $b->getOwner()->getId()) {
                return ($hierarchy[$a->getOwner()->getId()] < $hierarchy[$b->getOwner()->getId()]) ? 1 : -1;
            }

            return ($a->getSort() < $b->getSort()) ? -1 : 1;
        });

        return $blocks;
    }
440068
public function getTotalBlocksInAreaEditMode()
    {
        $db = Database::connection();
        return (int) $db->fetchColumn(
            'select count(b.bID) from CollectionVersionBlocks cvb inner join Blocks b on cvb.bID = b.bID inner join BlockTypes bt on b.btID = bt.btID where cID = ? and cvID = ? and arHandle = ?',
            array($this->c->getCollectionID(), $this->c->getVersionID(), $this->arHandle)
        );
    }
242948
public function getBlocks()
    {
        $sanitizedBlocks = [];

        foreach ($this->blocks as $block) {
            $sanitizedBlock = $this->handler->sanitizeBlock($block['type'], $block['data']);
            if (!empty($sanitizedBlock)) {
                array_push($sanitizedBlocks, $sanitizedBlock);
            }
        }

        return $sanitizedBlocks;
    }
1165906
public function getSortedModules()
    {
        $i18nOrder = Sources::config()->uninherited('module_priority');
        $sortedModules = [];
        if ($i18nOrder) {
            Deprecation::notice('5.0', sprintf(
                '%s.module_priority is deprecated. Use %s.module_priority instead.',
                __CLASS__,
                ModuleManifest::class
            ));
        }

        foreach (ModuleLoader::inst()->getManifest()->getModules() as $module) {
            $sortedModules[$module->getName()] = $module->getPath();
        };

        return $sortedModules;
    }