concrete/src/Block/BlockType/BlockType.php
public static function installBlockType($btHandle, $pkg = false)
    {
        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $pkgHandle = (string) (is_object($pkg) ? $pkg->getPackageHandle() : $pkg);
        $class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
        $bta = $app->build($class);

        $locator = $app->make(FileLocator::class);
        if ($pkgHandle !== '') {
            $locator->addLocation(new FileLocator\PackageLocation($pkgHandle));
        }
        $path = dirname($locator->getRecord(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB)->getFile());

        //Attempt to run the subclass methods (install schema from db.xml, etc.)
        $bta->install($path);

        // Prevent the database records being stored in wrong language
        $loc = $app->make(Localization::class);
        $loc->pushActiveContext(Localization::CONTEXT_SYSTEM);
        try {
            //Install the block
            $bt = new BlockTypeEntity();
            $bt->loadFromController($bta);
            if (is_object($pkg)) {
                $bt->setPackageID($pkg->getPackageID());
            }
            $bt->setBlockTypeHandle($btHandle);
        } finally {
            $loc->popActiveContext();
        }

        $em->persist($bt);
        $em->flush();

        if ($bta->getBlockTypeDefaultSet()) {
            $set = Set::getByHandle($bta->getBlockTypeDefaultSet());
            if ($set !== null) {
                $set->addBlockType($bt);
            }
        }

        return $bt;
    }
public static function installBlockType($btHandle, $pkg = false)
    {
        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $pkgHandle = (string) (is_object($pkg) ? $pkg->getPackageHandle() : $pkg);
        $class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
        $bta = $app->build($class);

        $locator = $app->make(FileLocator::class);
        if ($pkgHandle !== '') {
            $locator->addLocation(new FileLocator\PackageLocation($pkgHandle));
        }
        $path = dirname($locator->getRecord(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB)->getFile());

        //Attempt to run the subclass methods (install schema from db.xml, etc.)
        $bta->install($path);

        // Prevent the database records being stored in wrong language
        $loc = $app->make(Localization::class);
        $loc->pushActiveContext(Localization::CONTEXT_SYSTEM);
        try {
            //Install the block
            $bt = new BlockTypeEntity();
            $bt->loadFromController($bta);
            if (is_object($pkg)) {
                $bt->setPackageID($pkg->getPackageID());
            }
            $bt->setBlockTypeHandle($btHandle);
        } finally {
            $loc->popActiveContext();
        }

        $em->persist($bt);
        $em->flush();

        if ($bta->getBlockTypeDefaultSet()) {
            $set = Set::getByHandle($bta->getBlockTypeDefaultSet());
            if ($set !== null) {
                $set->addBlockType($bt);
            }
        }

        return $bt;
    }
public static function installBlockType ( $ btHandle , $ pkg = false ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ pkgHandle = ( string ) ( is_object ( $ pkg ) ? $ pkg -> getPackageHandle ( ) : $ pkg ) ; $ class = static :: getBlockTypeMappedClass ( $ btHandle , $ pkgHandle ) ; $ bta = $ app -> build ( $ class ) ; $ locator = $ app -> make ( FileLocator :: class ) ; if ( $ pkgHandle !== '' ) { $ locator -> addLocation ( new FileLocator \ PackageLocation ( $ pkgHandle ) ) ; } $ path = dirname ( $ locator -> getRecord ( DIRNAME_BLOCKS . '/' . $ btHandle . '/' . FILENAME_BLOCK_DB ) -> getFile ( ) ) ; //Attempt to run the subclass methods (install schema from db.xml, etc.) $ bta -> install ( $ path ) ; // Prevent the database records being stored in wrong language $ loc = $ app -> make ( Localization :: class ) ; $ loc -> pushActiveContext ( Localization :: CONTEXT_SYSTEM ) ; try { //Install the block $ bt = new BlockTypeEntity ( ) ; $ bt -> loadFromController ( $ bta ) ; if ( is_object ( $ pkg ) ) { $ bt -> setPackageID ( $ pkg -> getPackageID ( ) ) ; } $ bt -> setBlockTypeHandle ( $ btHandle ) ; } finally { $ loc -> popActiveContext ( ) ; } $ em -> persist ( $ bt ) ; $ em -> flush ( ) ; if ( $ bta -> getBlockTypeDefaultSet ( ) ) { $ set = Set :: getByHandle ( $ bta -> getBlockTypeDefaultSet ( ) ) ; if ( $ set !== null ) { $ set -> addBlockType ( $ bt ) ; } } return $ bt ; }
Install a BlockType that is passed via a btHandle string. The core or override directories are parsed.

@param string $btHandle The handle of the block type
@param \Concrete\Core\Entity\Package|\Concrete\Core\Package\Package|string|false $pkg The package owning the block type (or its handle)

@return \Concrete\Core\Entity\Block\BlockType\BlockType
Install a BlockType that is passed via a btHandle string . The core or override directories are parsed .