Returns block context instance.

@static
@param int $blockinstanceid id from {block_instances} table.
@param int $strictness
@return context_block context instance
500372
public static function instance($blockinstanceid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_BLOCK, $blockinstanceid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $blockinstanceid))) {
            if ($bi = $DB->get_record('block_instances', array('id' => $blockinstanceid), 'id,parentcontextid', $strictness)) {
                $parentcontext = context::instance_by_id($bi->parentcontextid);
                $record = context::insert_context_record(CONTEXT_BLOCK, $bi->id, $parentcontext->path);
            }
        }

        if ($record) {
            $context = new context_block($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
1137264
function proxy(context, strict) {
    return new Proxy(context || {}, {
        get(target, key) {
            if (key === symbol.map) return target
            if (key === "toString") return () => toPrimitive([target])
            if (Reflect.has(target, key)) return create(Reflect.get(target, key))

            if (!strict) return create([key])
        },
        set(target, key, value) {
            if (is.box(value)) {
                return Reflect.set(target, key, value)
            }
        },
        has(target, key) {
            return Reflect.has(target, key)
        }
    })
}
1176977
public function getContentIdByBlockId($id)
    {
        $dbHandler = $this->getConnection();
        $query = $dbHandler->createSelectQuery();
        $query
            ->select($dbHandler->quoteColumn('contentobject_id'))
            ->from($dbHandler->quoteTable('ezcontentobject_tree'))
            ->innerJoin(
                $dbHandler->quoteTable('ezm_block'),
                $query->expr->eq(
                    $dbHandler->quoteColumn('node_id', 'ezm_block'),
                    $dbHandler->quoteColumn('node_id', 'ezcontentobject_tree')
                )
            )
            ->where(
                $query->expr->eq(
                    $dbHandler->quoteColumn('id', 'ezm_block'),
                    $query->bindValue($id, null, PDO::PARAM_STR)
                )
            );

        $stmt = $query->prepare();
        $stmt->execute();

        $contentId = $stmt->fetchColumn();

        if ($contentId === false) {
            throw new NotFoundException('Block', $id);
        }

        return $contentId;
    }
493585
function Block(options) {
  if (!(this instanceof Block))
    return new Block(options);

  AbstractBlock.call(this);

  this.txs = [];

  this._raw = null;
  this._size = -1;
  this._witness = -1;

  if (options)
    this.fromOptions(options);
}
1056071
static BlockCanaryInternals getInstance() {
        if (sInstance == null) {
            synchronized (BlockCanaryInternals.class) {
                if (sInstance == null) {
                    sInstance = new BlockCanaryInternals();
                }
            }
        }
        return sInstance;
    }
1164160
public static <S, L> Collection<S> getStatesInBlock(Block<S, L> block) {
        return new OriginalStateCollection<>(block.getStates());
    }
141427
function resolveInstanceById(refId){
  var templateId = refId & 0xFFF;
  var instanceId = refId >> 12;
  var templateInfo = templates[templateId];

  return templateInfo && templateInfo.instances[instanceId];
}
342771
public static function getDocBlockFactory(): DocBlockFactory
    {
        if (is_null(self::$docBlockFactory)) {
            self::$docBlockFactory = DocBlockFactory::createInstance();
        }

        return self::$docBlockFactory;
    }
1061104
public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
    {
        /** @var Statistics $statistics */
        $statistics = app(Statistics::class);

        $content = '<div class="logged_in_count">' . $statistics->usersLoggedInList() . '</div>';

        if ($ctype !== '') {
            return view('modules/block-template', [
                'block'      => Str::kebab($this->name()),
                'id'         => $block_id,
                'config_url' => '',
                'title'      => $this->title(),
                'content'    => $content,
            ]);
        }

        return $content;
    }
1153639
public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
    {
        $statistics = app(Statistics::class);

        $title          = $this->getBlockSetting($block_id, 'title', '');
        $content        = $this->getBlockSetting($block_id, 'html', '');
        $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
        $languages      = $this->getBlockSetting($block_id, 'languages');

        // Only show this block for certain languages
        if ($languages && !in_array(WT_LOCALE, explode(',', $languages), true)) {
            return '';
        }

        // Retrieve text, process embedded variables
        $title   = $statistics->embedTags($title);
        $content = $statistics->embedTags($content);

        $block_timestamp = (int) $this->getBlockSetting($block_id, 'timestamp', (string) Carbon::now()->unix());

        if ($show_timestamp === '1') {
            $content .= '<br>' . view('components/datetime', ['timestamp' => Carbon::createFromTimestamp($block_timestamp)]);
        }

        if ($ctype !== '') {
            if ($ctype === 'gedcom' && Auth::isManager($tree)) {
                $config_url = route('tree-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } elseif ($ctype === 'user' && Auth::check()) {
                $config_url = route('user-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } else {
                $config_url = '';
            }

            return view('modules/block-template', [
                'block'      => Str::kebab($this->name()),
                'id'         => $block_id,
                'config_url' => $config_url,
                'title'      => $title,
                'content'    => $content,
            ]);
        }

        return $content;
    }
732062
public BlockInfo getInfo(long blockId) throws IOException {
    try (CloseableResource<BlockMasterClient> masterClientResource =
        mContext.acquireBlockMasterClientResource()) {
      return masterClientResource.get().getBlockInfo(blockId);
    }
  }
258420
protected static function blockBegin(&$context, $vars) {
        switch ((isset($vars[0][0]) && is_string($vars[0][0])) ? $vars[0][0] : null) {
            case 'with':
                return static::with($context, $vars);
            case 'each':
                return static::section($context, $vars, true);
            case 'unless':
                return static::unless($context, $vars);
            case 'if':
                return static::doIf($context, $vars);
            default:
                return static::section($context, $vars);
        }
    }
1214570
public function getContentIdByBlockId($id)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select($this->connection->quoteIdentifier('contentobject_id'))
            ->from($this->connection->quoteIdentifier('ezcontentobject_tree'), 't')
            ->innerJoin(
                't',
                $this->connection->quoteIdentifier(self::EZM_BLOCK_TABLE),
                'b',
                $query->expr()->eq(
                    $this->connection->quoteIdentifier('b.node_id'),
                    $this->connection->quoteIdentifier('t.node_id')
                )
            )
            ->where(
                $query->expr()->eq($this->connection->quoteIdentifier('b.id'), ':id')
            )
            ->setParameter(':id', $id, PDO::PARAM_STR)
        ;

        $statement = $query->execute();

        $contentId = $statement->fetchColumn();
        if ($contentId === false) {
            throw new NotFoundException('Block', $id);
        }

        return $contentId;
    }
1209302
def _parse_block_ref(cls, block_ref, deprecated=False):
        

        if deprecated and block_ref is None:
            return None

        if isinstance(block_ref, LocalId):
            return block_ref

        is_valid_deprecated = deprecated and cls.DEPRECATED_ALLOWED_ID_RE.match(block_ref)
        is_valid = cls.ALLOWED_ID_RE.match(block_ref)

        if is_valid or is_valid_deprecated:
            return block_ref
        else:
            raise InvalidKeyError(cls, block_ref)
1035059
public BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException {
    BlockMeta blockMeta = mBlockIdToBlockMap.get(blockId);
    if (blockMeta == null) {
      throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_META_NOT_FOUND, blockId);
    }
    return blockMeta;
  }
186472
protected function createResponse(BlockContextInterface $blockContext, Response $response = null)
    {
        if (null === $response) {
            $response = new Response();
        }

        // set the ttl from the block instance, this can be changed by the BlockService
        if (($ttl = $blockContext->getBlock()->getTtl()) > 0) {
            $response->setTtl($ttl);
        }

        return $response;
    }
227046
public static function instance($categoryid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_COURSECAT, $categoryid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_COURSECAT, 'instanceid' => $categoryid))) {
            if ($category = $DB->get_record('course_categories', array('id' => $categoryid), 'id,parent', $strictness)) {
                if ($category->parent) {
                    $parentcontext = context_coursecat::instance($category->parent);
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, $parentcontext->path);
                } else {
                    $record = context::insert_context_record(CONTEXT_COURSECAT, $category->id, '/'.SYSCONTEXTID, 0);
                }
            }
        }

        if ($record) {
            $context = new context_coursecat($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }