當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Package::getClass方法代碼示例

本文整理匯總了PHP中Package::getClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Package::getClass方法的具體用法?PHP Package::getClass怎麽用?PHP Package::getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Package的用法示例。


在下文中一共展示了Package::getClass方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public function execute(Batch $batch)
 {
     $packages = $batch->getObjectCollection('package');
     if (!$packages) {
         return;
     }
     foreach ($packages->getPackages() as $package) {
         if (!$package->getPublisherValidator()->skipItem()) {
             $pkg = \Package::getClass($package->getHandle());
             if (!$pkg->isPackageInstalled()) {
                 $pkg->install();
             }
         }
     }
 }
開發者ID:motoki1199,項目名稱:addon_migration_tool,代碼行數:15,代碼來源:CreatePackagesRoutine.php

示例2: registerPackage

 public function registerPackage($pkg)
 {
     if (is_string($pkg)) {
         $pkg = \Package::getClass($pkg);
     }
     $pkgHandle = $pkg->getPackageHandle();
     $loader = new ModifiedPSR4ClassLoader();
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Attribute', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_ATTRIBUTES);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\MenuItem', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_MENU_ITEMS);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Authentication', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_AUTHENTICATION);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Block', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_BLOCKS);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Theme', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_THEMES);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Controller\\PageType', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Controller', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CONTROLLERS);
     $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Job', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_JOBS);
     $this->loaders[] = $loader;
     $loader->register();
     $loader = new Psr4ClassLoader();
     $loaders = $pkg->getPackageAutoloaderRegistries();
     if (count($loaders) > 0) {
         foreach ($loaders as $path => $prefix) {
             $loader->addPrefix($prefix, DIR_PACKAGES . '/' . $pkgHandle . '/' . $path);
         }
     }
     /** @type Package $pkg */
     if (!$pkg->shouldEnableLegacyNamespace()) {
         // We map all src files in the package to the src/Concrete directory
         $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle), DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CLASSES . '/Concrete');
         $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Entity', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CLASSES . '/Entity');
     } else {
         // legacy Src support
         $loader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Src', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CLASSES);
     }
     $this->loaders[] = $loader;
     $loader->register();
     $this->registerPackageController($pkgHandle);
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:37,代碼來源:ClassLoader.php

示例3: registerPackage

 /**
  * Registers the prefixes for a package
  *
  * The following prefixes are registered:
  * <ul>
  * <li>`Concrete\Package\PkgHandle\Attribute` -> `packages/pkg_handle/attributes`</li>
  * <li>`Concrete\Package\PkgHandle\MenuItem` -> `packages/pkg_handle/menu_items`</li>
  * <li>`Concrete\Package\PkgHandle\Authentication` -> `packages/pkg_handle/authentication`</li>
  * <li>`Concrete\Package\PkgHandle\Block` -> `packages/pkg_handle/blocks`</li>
  * <li>`Concrete\Package\PkgHandle\Theme` -> `packages/pkg_handle/themes`</li>
  * <li>`Concrete\Package\PkgHandle\Controller\PageType` -> `packages/pkg_handle/controllers/page_type`</li>
  * <li>`Concrete\Package\PkgHandle\Controller` -> `packages/pkg_handle/controllers`</li>
  * <li>`Concrete\Package\PkgHandle\Job` -> `packages/pkg_handle/jobs`</li>
  * </ul>
  *
  * If Package::$pkgAutoloaderMapCoreExtensions is true, all remaining class paths will be checked for
  * under packages/pkg_handle/src/Concrete
  *
  * Otherwise, `Concrete\Package\PkgHandle\Src` -> `packages/pkg_handle/src` will be registered
  *
  * The function Package::getPackageAutoloaderRegistries() can be used to add custom prefixes
  *
  * @param string|\Package $pkg Package handle or an instance of the package controller
  * @see Package::$pkgAutoloaderMapCoreExtensions, Package::getPackageAutoloaderRegistries()
  */
 public function registerPackage($pkg)
 {
     if (!$pkg instanceof Package) {
         $pkg = \Package::getClass($pkg);
     }
     $pkgHandle = $pkg->getPackageHandle();
     $symfonyLoader = new ModifiedPSR4ClassLoader();
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Attribute', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_ATTRIBUTES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\MenuItem', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_MENU_ITEMS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Authentication', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_AUTHENTICATION);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Block', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_BLOCKS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Theme', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_THEMES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Controller\\PageType', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Controller', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CONTROLLERS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Job', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_JOBS);
     $strictLoader = new SymfonyClassLoader();
     $loaders = $pkg->getPackageAutoloaderRegistries();
     if (count($loaders) > 0) {
         foreach ($loaders as $path => $prefix) {
             $strictLoader->addPrefix($prefix, DIR_PACKAGES . '/' . $pkgHandle . '/' . $path);
         }
     }
     if ($pkg->providesCoreExtensionAutoloaderMapping()) {
         // We map all src files in the package to the src/Concrete directory
         $strictLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle), DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CLASSES . '/Concrete');
     } else {
         // legacy Src support
         $strictLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkgHandle) . '\\Src', DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_CLASSES);
     }
     $symfonyLoader->register();
     $strictLoader->register();
     $this->registerPackageController($pkgHandle);
 }
開發者ID:ceko,項目名稱:concrete5-1,代碼行數:58,代碼來源:ClassLoader.php

示例4: core_class

/**
 *  Returns a concrete5 namespaced class. $prefix is either true (for application), or a package handle or null.
 *
 * @param string $class
 * @param bool   $prefix
 * @return string
 */
function core_class($class, $prefix = false)
{
    $class = trim($class, '\\');
    if ($prefix) {
        if (substr($class, 0, 5) == "Core\\") {
            if ($prefix !== true) {
                $x = \Package::getClass($prefix);
                if ($x->providesCoreExtensionAutoloaderMapping()) {
                    $class = substr($class, 5);
                } else {
                    $class = "Src\\" . substr($class, 5);
                }
            } else {
                if (Config::get('app.provide_core_extension_autoloader_mapping')) {
                    $class = substr($class, 5);
                } else {
                    $class = "Src\\" . substr($class, 5);
                }
            }
        }
        if ($prefix === true) {
            $prefix = Config::get('app.namespace');
        } else {
            $prefix = 'Concrete\\Package\\' . camelcase($prefix);
        }
    }
    if (!$prefix) {
        $prefix = 'Concrete';
    }
    $class = '\\' . $prefix . '\\' . $class;
    return $class;
}
開發者ID:ceko,項目名稱:concrete5-1,代碼行數:39,代碼來源:helpers.php

示例5: registerPackageCustomAutoloaders

 public function registerPackageCustomAutoloaders($pkg)
 {
     if (is_string($pkg)) {
         $pkg = \Package::getClass($pkg);
     }
     $pkgHandle = $pkg->getPackageHandle();
     $loader = new Psr4ClassLoader();
     $loaders = $pkg->getPackageAutoloaderRegistries();
     if (count($loaders) > 0) {
         foreach ($loaders as $path => $prefix) {
             $loader->addPrefix($prefix, DIR_PACKAGES . '/' . $pkgHandle . '/' . $path);
         }
     }
     $this->loaders[] = $loader;
     $loader->register();
 }
開發者ID:seebaermichi,項目名稱:concrete5,代碼行數:16,代碼來源:ClassLoader.php


注:本文中的Package::getClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。