Prepares the given threaded list of terms.

@param array $terms Threaded list of terms
@param \Cake\Datasource\EntityInterface $block The block
497704
public static function termsForBlock($terms, $block)
    {
        foreach ($terms as $term) {
            $title = $term->name;
            if (!empty($block->settings['show_counters'])) {
                $countCacheKey = "t{$term->id}";
                $count = (string)Cache::read($countCacheKey, 'terms_count');
                if ($count == '') {
                    $count = (int)TableRegistry::get('Taxonomy.EntitiesTerms')
                        ->find()
                        ->where(['EntitiesTerms.term_id' => $term->id])
                        ->count();
                    Cache::write($countCacheKey, $count, 'terms_count');
                }
                $title .= " ({$count})";
            }

            $term->set('title', $title);
            $term->set('url', "/find/term:{$term->slug}");

            if (!empty($term->children)) {
                $term->set('expanded', true);
                static::termsForBlock($term->children, $block);
            }
        }
    }
689688
protected function assembleDocBlock($docBlock, $target)
    {
        if (!$docBlock) {
            return;
        }

        $target->setSummary($docBlock->getSummary());
        $target->setDescription($docBlock->getDescription());

        /** @var DocBlock\Tag $tag */
        foreach ($docBlock->getTags() as $tag) {
            $tagDescriptor = $this->builder->buildDescriptor($tag);

            // allow filtering of tags
            if (!$tagDescriptor) {
                continue;
            }

            $target->getTags()
                ->get($tag->getName(), new Collection())
                ->add($tagDescriptor);
        }
    }
1008540
protected function setResponseHeaders(BlockInterface $block, Response $response)
    {
        if ($block && $block->getReference()) {
            if ($this->getReferenceService($block)->isEsiEnabled($block->getReference())) {
                $this->getReferenceService($block)->setResponseHeaders($block->getReference(), $response);
            } else {
                $response->setLastModified($block->getReference()->getUpdatedAt());
                $response->setPublic();
            }
        }
    }
500655
protected function prepare_terms( $field, $terms, $taxonomy ) {
		if ( 'id' === $field ) {
			$new_terms = [];
			foreach ( $terms as $term_id ) {
				$term = get_term_by( 'term_id', $term_id, $taxonomy );
				if ( $term ) {
					$new_terms[] = $term->slug;
				}
			}
			$terms = $new_terms;
		}
		return $terms;
	}
1198543
private function prepare(
        SpecificationInterface $specification,
        EntityManager $entityManager,
        QueryBuilder $queryBuilder,
        AbstractQuery $query
    ) {
        $entityManager->createQueryBuilder()->willReturn($queryBuilder);

        $specification->modify($queryBuilder, $this->dqlAlias)->willReturn($this->expression);

        $queryBuilder->select($this->dqlAlias)->willreturn($queryBuilder);
        $queryBuilder->from(Argument::any(), $this->dqlAlias, Argument::any())->willReturn($queryBuilder);
        $queryBuilder->where($this->expression)->willReturn($queryBuilder);

        $queryBuilder->getQuery()->willReturn($query);

        $query->execute()->willReturn($this->result);
    }
529215
public function addBlock(ExecutionBlockInterface $block): int
    {
        if ($block instanceof ProcedureBlockInterface) {
            $index = $this->serializeProcedure($block);
        } elseif ($block instanceof IfExpressionInterface) {
            $index = $this->serializeIfExpression($block);
        } elseif ($block instanceof AndExpressionInterface) {
            $index = $this->serializeAndExpression($block);
        } elseif ($block instanceof OrExpressionInterface) {
            $index = $this->serializeOrExpression($block);
        } else {
            // unknown execution block type
            throw new UnknownExecutionBlockType();
        }

        return $index;
    }
1129468
private function initBlocks()
    {
        $timetableBlocks = $this->repository->findBlocksByTimetableIdOnly($this->timetable->getId());

        if (count($timetableBlocks) > 0) {
            $blocks = array();

            foreach ($timetableBlocks as $block) {
                $blocks[$block->getDomId()] = $block;
            }
            if (count($blocks) > 0) {
                $this->timetable->setBlocks($blocks);
            }
        }
    }
826898
private function processCollections(Block $block, array $collectionsData): void
    {
        foreach ($block->getCollections() as $identifier => $collection) {
            $collectionData = $collectionsData[$identifier];

            $collectionQuery = $collection->getQuery();

            if ($collectionQuery instanceof Query && is_array($collectionData['query'])) {
                $this->updateQueryTranslations(
                    $collectionQuery,
                    $collectionData['query']['parameters']
                );
            }

            $this->createItems($collection, $collectionData['items']);
        }
    }
331266
public function setUpBlockManagers(array $blocks)
    {
        foreach ($blocks as $block) {
            $blockManager = $this->blockManagerFactory->createBlockManager($block);
            if (null === $blockManager) {
                continue;
            }
            $this->blockManagersCollection->addBlockManager($blockManager);
        }
    }
945429
private function copyBlockCollections(Block $block, Block $targetBlock): void
    {
        $collectionReferences = $this->loadCollectionReferences($block);

        foreach ($collectionReferences as $collectionReference) {
            $collection = $this->collectionHandler->loadCollection(
                $collectionReference->collectionId,
                $collectionReference->collectionStatus
            );

            $collection = $this->collectionHandler->copyCollection($collection);

            $newCollectionReference = CollectionReference::fromArray(
                [
                    'blockId' => $targetBlock->id,
                    'blockStatus' => $targetBlock->status,
                    'collectionId' => $collection->id,
                    'collectionStatus' => $collection->status,
                    'identifier' => $collectionReference->identifier,
                ]
            );

            $this->queryHandler->createCollectionReference($newCollectionReference);
        }
    }
1085747
public function setTerms($terms, $vocabulary_id = null)
    {
        $this->removeTerms($vocabulary_id);

        foreach ($terms as $term_id) {
            $this->addTerm($term_id);
        }
    }
1072250
def setTerms( self, terms ):
        
        self.uiTermDDL.blockSignals(True)
        
        term = self.uiTermDDL.currentText()
        self.uiTermDDL.clear()
        self.uiTermDDL.addItems(terms)
        self.uiTermDDL.setCurrentIndex(self.uiTermDDL.findText(term))
        self.applyRule()
        self.uiTermDDL.blockSignals(False)
1275357
protected function blockDefinitionList($Line, $Block)
    {
        if ( ! isset($Block) or isset($Block['type']))
        {
            return;
        }

        $Element = array(
            'name' => 'dl',
            'elements' => array(),
        );

        $terms = explode("\n", $Block['element']['handler']['argument']);

        foreach ($terms as $term)
        {
            $Element['elements'] []= array(
                'name' => 'dt',
                'handler' => array(
                    'function' => 'lineElements',
                    'argument' => $term,
                    'destination' => 'elements'
                ),
            );
        }

        $Block['element'] = $Element;

        $Block = $this->addDdElement($Line, $Block);

        return $Block;
    }
629736
private function internalDisableTranslations(PersistenceBlock $block): PersistenceBlock
    {
        $block = $this->blockHandler->updateBlock(
            $block,
            BlockUpdateStruct::fromArray(
                [
                    'isTranslatable' => false,
                ]
            )
        );

        foreach ($block->availableLocales as $locale) {
            if ($locale !== $block->mainLocale) {
                $block = $this->blockHandler->deleteBlockTranslation(
                    $block,
                    $locale
                );
            }
        }

        foreach ($this->blockHandler->loadChildBlocks($block) as $childBlock) {
            $this->internalDisableTranslations($childBlock);
        }

        return $block;
    }
1303025
public function update(Model\BlockInterface $block, Request $request)
    {
        // Plugin update
        return $this->editor
            ->getBlockPlugin($block->getType())
            ->update($block, $request);
    }
191040
public function _processClassDocBlock($block)
    {
        $result = [];
        if ($block instanceof \Zend\Code\Reflection\DocBlockReflection) {
            $docBlockLines = $block->getContents();
            $docBlockLines = explode("\n", $docBlockLines);
            foreach ($docBlockLines as $line) {
                $methodData = $this->_processClassDocLine($line);
                if ($methodData) {
                    $name = $methodData->getName();
                    $result[$name] = $methodData;
                }
            }
        }
        return $result;
    }
627912
protected function prepareBlockControllers()
	{
		$pageRequest = $this->pageRequest;

		$this->iterateBlocks(function(Block $block, BlockController $blockController) use ($pageRequest) {
				$blockController->prepare($pageRequest);
		});
	}