concrete/src/Application/Service/Urls.php
public function getBlockTypeAssetsURL($bt, $file = false)
    {
        $ff = '';
        if ($file != false) {
            $ff = '/' . $file;
        }
        $url = '';
        $packageHandle = null;

        if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $bt->getBlockTypeHandle() . $ff)) {
            $url = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
        } elseif ($bt->getPackageID() > 0) {
            $packageHandle = $bt->getPackageHandle();
            $dirp = (is_dir(DIR_PACKAGES . '/' . $packageHandle)) ? DIR_PACKAGES . '/' . $packageHandle : DIR_PACKAGES_CORE . '/' . $packageHandle;
            if (file_exists($dirp . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff)) {
                $url = (is_dir(DIR_PACKAGES . '/' . $packageHandle)) ? DIR_REL : ASSETS_URL;
                $url = $url . '/' . DIRNAME_PACKAGES . '/' . $packageHandle . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
            }
        } elseif (file_exists(DIR_FILES_BLOCK_TYPES_CORE . '/' . $bt->getBlockTypeHandle() . $ff)) {
            $url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
        }
        if ($url && $file) {
            $asset = null;
            if (substr($file, -3) === '.js') {
                $asset = new JavascriptAsset('');
            } elseif (substr($file, -3) === '.css') {
                $asset = new CssAsset('');
            }
            if ($asset !== null) {
                $asset->setAssetIsLocal(true);
                $asset->setAssetURL($url);
                if ($packageHandle) {
                    $app = Application::getFacadeApplication();
                    $em = $app->make(EntityManagerInterface::class);
                    $repo = $em->getRepository(Package::class);
                    $asset->setPackageObject($repo->findOneBy(['pkgHandle' => $packageHandle]));
                }
                $url = $asset->getAssetURL();
            }
        }

        return $url;
    }
public function getBlockTypeAssetsURL($bt, $file = false)
    {
        $ff = '';
        if ($file != false) {
            $ff = '/' . $file;
        }
        $url = '';
        $packageHandle = null;

        if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $bt->getBlockTypeHandle() . $ff)) {
            $url = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
        } elseif ($bt->getPackageID() > 0) {
            $packageHandle = $bt->getPackageHandle();
            $dirp = (is_dir(DIR_PACKAGES . '/' . $packageHandle)) ? DIR_PACKAGES . '/' . $packageHandle : DIR_PACKAGES_CORE . '/' . $packageHandle;
            if (file_exists($dirp . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff)) {
                $url = (is_dir(DIR_PACKAGES . '/' . $packageHandle)) ? DIR_REL : ASSETS_URL;
                $url = $url . '/' . DIRNAME_PACKAGES . '/' . $packageHandle . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
            }
        } elseif (file_exists(DIR_FILES_BLOCK_TYPES_CORE . '/' . $bt->getBlockTypeHandle() . $ff)) {
            $url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
        }
        if ($url && $file) {
            $asset = null;
            if (substr($file, -3) === '.js') {
                $asset = new JavascriptAsset('');
            } elseif (substr($file, -3) === '.css') {
                $asset = new CssAsset('');
            }
            if ($asset !== null) {
                $asset->setAssetIsLocal(true);
                $asset->setAssetURL($url);
                if ($packageHandle) {
                    $app = Application::getFacadeApplication();
                    $em = $app->make(EntityManagerInterface::class);
                    $repo = $em->getRepository(Package::class);
                    $asset->setPackageObject($repo->findOneBy(['pkgHandle' => $packageHandle]));
                }
                $url = $asset->getAssetURL();
            }
        }

        return $url;
    }
public function getBlockTypeAssetsURL ( $ bt , $ file = false ) { $ ff = '' ; if ( $ file != false ) { $ ff = '/' . $ file ; } $ url = '' ; $ packageHandle = null ; if ( file_exists ( DIR_FILES_BLOCK_TYPES . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } elseif ( $ bt -> getPackageID ( ) > 0 ) { $ packageHandle = $ bt -> getPackageHandle ( ) ; $ dirp = ( is_dir ( DIR_PACKAGES . '/' . $ packageHandle ) ) ? DIR_PACKAGES . '/' . $ packageHandle : DIR_PACKAGES_CORE . '/' . $ packageHandle ; if ( file_exists ( $ dirp . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = ( is_dir ( DIR_PACKAGES . '/' . $ packageHandle ) ) ? DIR_REL : ASSETS_URL ; $ url = $ url . '/' . DIRNAME_PACKAGES . '/' . $ packageHandle . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } } elseif ( file_exists ( DIR_FILES_BLOCK_TYPES_CORE . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } if ( $ url && $ file ) { $ asset = null ; if ( substr ( $ file , - 3 ) === '.js' ) { $ asset = new JavascriptAsset ( '' ) ; } elseif ( substr ( $ file , - 3 ) === '.css' ) { $ asset = new CssAsset ( '' ) ; } if ( $ asset !== null ) { $ asset -> setAssetIsLocal ( true ) ; $ asset -> setAssetURL ( $ url ) ; if ( $ packageHandle ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ repo = $ em -> getRepository ( Package :: class ) ; $ asset -> setPackageObject ( $ repo -> findOneBy ( [ 'pkgHandle' => $ packageHandle ] ) ) ; } $ url = $ asset -> getAssetURL ( ) ; } } return $ url ; }
Gets a full URL to the directory containing all of a block's items, including JavaScript, tools, icons, etc...

@param \Concrete\Core\Entity\Block\BlockType\BlockType $bt
@param bool|string $file If provided will get the assets url for a file in a block

@return string $url
Gets a full URL to the directory containing all of a block s items including JavaScript tools icons etc ...