Apply sanitizing rules according to the block type

@param string $blockType
@param array  $blockData

@throws EditorJSException

@return array|bool
491130
public function sanitizeBlock($blockType, $blockData)
    {
        $rule = $this->rules->tools[$blockType];

        return [
            'type' => $blockType,
            'data' => $this->sanitize($rule, $blockData)
        ];
    }
52505
private function sanitizeSubstitutionData(array $substitutionData)
    {
        $sanitized = [];

        foreach ($substitutionData as $key => $value) {
            $sanitized[(string) $key] = (string) $value;
        }

        return $sanitized;
    }
778895
public function deleteBlockType(SuperTableBlockTypeModel $blockType): bool
    {
        Craft::$app->getProjectConfig()->remove(self::CONFIG_BLOCKTYPE_KEY . '.' . $blockType->uid);

        return true;
    }
873569
public static function block_field_types() {

		static $field_types = null;

		if ( null === $field_types ) {
			$field_types = array( 'heading', 'html' );

			/**
			 * Returns the available text field types
			 *
			 * @since unknown
			 *
			 * @param object $field_types Outputs the field types
			 */

			$field_types = apply_filters( 'pods_block_field_types', $field_types );
		}

		return $field_types;
	}
322624
@Override
	protected void writeDataBlock(byte[] data, int offset, int len, int blockHandle) throws DataStoreException
    {
    	byte[] blockData = new byte[blockSize];
    	System.arraycopy(data, offset, blockData, 0, len);
    	
    	dirtyBlockTable.markDirty(blockHandle, blockData);    	
    	journal.writeDataBlock(blockHandle, (long)blockHandle*blockSize, blockData);
    }
481597
public function edit(BlockRequest $request, Block $block)
    {
        return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('block::block.name'))
            ->view('block::admin.block.edit')
            ->data(compact('block'))
            ->output();
    }
625235
public function validateDocBlocks($data)
    {
        /** @var \phpDocumentor\Reflection\BaseReflector $element */
        $element = $data->getSubject();

        /** @var \phpDocumentor\Reflection\DocBlock $docblock */
        $docblock = $data->getDocblock();

        // get the type of element
        $type = substr(
            get_class($element),
            strrpos(get_class($element), '\\') + 1,
            -9 // Reflector
        );

        // no docblock, or docblock should be ignored, so no reason to validate
        if ($docblock && $docblock->hasTag('ignore')) {
            return;
        }

        $validatorOptions = $this->loadConfiguration();

        foreach (array('Deprecated', 'Required', $type) as $validator) {

            // todo: move to a factory or builder class
            $class = 'phpDocumentor\Plugin\Core\Parser\DocBlock\Validator\\' . $validator . 'Validator';
            if (class_exists($class)) {
                /** @var ValidatorAbstract $val */
                $val = new $class($element->getName(), $docblock, $element);
                $val->setOptions($validatorOptions);
                $val->isValid($element);
            }
        }
    }
1318885
protected function ensureInitialized($blockType)
    {
        if ($blockType instanceof BlockTypeInterface) {
            $name = $blockType->getName();
            $type = $blockType;
        } else {
            $name = $blockType;
            $type = null;
        }

        if (!isset($this->types[$name])) {
            if (!$type) {
                $type = $this->registry->getType($name);
            }

            $types      = [$type];
            $typeName   = $type->getName();
            $names      = [$typeName];
            $nameMap    = [$typeName => true];
            $parentName = $type->getParent();
            while ($parentName) {
                if (isset($this->types[$parentName])) {
                    // use data from already loaded parent type
                    $types   = array_merge($this->types[$parentName], array_reverse($types));
                    $names   = array_merge($this->names[$parentName], array_reverse($names));
                    $nameMap = array_merge($nameMap, $this->nameMap[$parentName]);
                    break;
                } else {
                    $type     = $this->registry->getType($parentName);
                    $typeName = $type->getName();

                    $types[]            = $type;
                    $names[]            = $typeName;
                    $nameMap[$typeName] = true;

                    $parentName = $type->getParent();
                }
            }

            if (null === $parentName) {
                $types = array_reverse($types);
                $names = array_reverse($names);
            }

            $this->types[$name]   = $types;
            $this->names[$name]   = $names;
            $this->nameMap[$name] = $nameMap;

            // initialise all parent types if them are not initialized yet
            $typeNames = array_keys($nameMap);
            $offset    = 0;
            while (false !== ($typeName = next($typeNames))) {
                if (isset($this->nameMap[$typeName])) {
                    break;
                }

                $offset++;
                $this->types[$typeName]   = array_slice($types, 0, -$offset);
                $this->names[$typeName]   = array_slice($names, 0, -$offset);
                $this->nameMap[$typeName] = array_slice($nameMap, $offset);
            }
        }

        return $name;
    }
412386
public function detach($blockTypeId, $fieldId)
    {
        try {
            $this->blockTypeFields->detach($blockTypeId, $fieldId);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.detach', ['object' => trans('soda::terminology.field')]));
        }

        return redirect()->route('soda.block-types.edit', [$blockTypeId, 'tab' => 'fields'])->with('success', trans('soda::messages.detached', ['object' => trans('soda::terminology.field')]));
    }
568969
public function render(AbstractBlock $block, CliRenderer $renderer)
    {
        if (!($block instanceof Document)) {
            throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
        }

        $wholeDoc = $renderer->renderBlocks($block->children());
        return $wholeDoc === '' ? '' : $wholeDoc . "\n";
    }
597320
public function isEditable()
    {
        $bv = new BlockView($this);
        $path = $bv->getBlockPath(FILENAME_BLOCK_EDIT);
        if (file_exists($path . '/' . FILENAME_BLOCK_EDIT)) {
            return true;
        }

        return false;
    }
893076
protected function processBlocks(string &$content): void
    {
        $pattern = $this->getTagPattern('block\s+([_a-zA-Z][_a-zA-Z0-9]*)' . preg_quote($this->endTag, '/') . '\s*(.+?)\s*' . preg_quote($this->startTag . '/block', '/'));
        $blockCodes = [];
        $content = preg_replace_callback($pattern, function ($match) use (&$blockCodes) {
            $blockCodes[$match[1]] = $match[2];
            return '';
        }, $content);
        $displayPattern = $this->getTagPattern('display_block\s+([_a-zA-Z][_a-zA-Z0-9]*)');
        $content = preg_replace_callback($displayPattern, function ($match) use ($blockCodes) {
            if (isset($blockCodes[$match[1]])) {
                return $blockCodes[$match[1]];
            }
            return '';
        }, $content);
    }
676171
private function validateBlockTypes(array $blockTypes, array $blockDefinitions): void
    {
        foreach ($blockTypes as $identifier => $blockType) {
            if (!isset($blockDefinitions[$blockType['definition_identifier']])) {
                throw new RuntimeException(
                    sprintf(
                        'Block definition "%s" used in "%s" block type does not exist.',
                        $blockType['definition_identifier'],
                        $identifier
                    )
                );
            }
        }
    }
1222016
function(source, type) {
  if (source.hasOwnProperty('format')) {
    if (source.format !== type) {
      if (source.format === 'section') {
        var blocks = [];
        source.blocks.forEach(function(val, index, array) {
          var block = deleteTextBlockFormat(val, type);
          if (block) {
            blocks.push(block);
          }
        });
        if (blocks.length) {
          return {format: 'section', blocks: blocks};
        } else {
          return null;
        }
      } else {
        return source;
      }
    } else {
      return null;
    }
  }
  throw new Error('invalid format for textblock (did you pass an Object in?)');
}
1163920
private function updateBlockTranslations(Block $block, array $translationsData): void
    {
        $mainLocale = $block->getMainLocale();

        foreach ($block->getAvailableLocales() as $locale) {
            if ($locale === $mainLocale) {
                continue;
            }

            if (!array_key_exists($locale, $translationsData)) {
                throw new RuntimeException(
                    sprintf('Could not find locale "%s" in the given block data', $locale)
                );
            }

            $this->updateBlockTranslation($block, $translationsData[$locale], $locale);
        }
    }
396103
private function createBlock(Block $targetBlock, string $placeholder, array $blockData): Block
    {
        $blockCreateStruct = $this->buildBlockCreateStruct($blockData);
        $block = $this->blockService->createBlock($blockCreateStruct, $targetBlock, $placeholder);

        $this->updateBlockTranslations($block, $blockData['parameters']);
        $this->processPlaceholderBlocks($block, $blockData['placeholders']);
        $this->processCollections($block, $blockData['collections']);

        return $block;
    }
431766
private static function concatenateBlocklist($blocklistContent)
    {
        return self::SEPERATOR . str_replace(PHP_EOL, self::SEPERATOR, strtolower($blocklistContent)) . self::SEPERATOR;
    }