本文整理汇总了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();
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}