本文整理汇总了PHP中KAutoloader::getClassMap方法的典型用法代码示例。如果您正苦于以下问题:PHP KAutoloader::getClassMap方法的具体用法?PHP KAutoloader::getClassMap怎么用?PHP KAutoloader::getClassMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KAutoloader
的用法示例。
在下文中一共展示了KAutoloader::getClassMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheMap
static function cacheMap($servicePath, $cacheFilePath)
{
if (!is_dir($servicePath)) {
throw new Exception('Invalid directory [' . $servicePath . ']');
}
$servicePath = realpath($servicePath);
$serviceMap = array();
$classMap = KAutoloader::getClassMap();
$checkedClasses = array();
foreach ($classMap as $class => $classFilePath) {
$classFilePath = realpath($classFilePath);
if (strpos($classFilePath, $servicePath) === 0) {
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isSubclassOf('KalturaBaseService')) {
$docComment = $reflectionClass->getDocComment();
$parser = new KalturaDocCommentParser($docComment);
$serviceId = strtolower($parser->serviceName);
$serviceMap[$serviceId] = $class;
}
}
$checkedClasses[] = $class;
}
$pluginServices = array();
$pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaServices');
foreach ($pluginInstances as $pluginName => $pluginInstance) {
$pluginServices = $pluginInstance->getServicesMap();
foreach ($pluginServices as $serviceName => $serviceClass) {
$serviceName = strtolower($serviceName);
$serviceId = "{$pluginName}_{$serviceName}";
$pluginServices[$serviceId] = $serviceClass;
$serviceMap[$serviceId] = $serviceClass;
}
}
$cachedFile = '';
$cachedFile .= '<?php' . PHP_EOL;
$cachedFile .= 'self::$services = ' . var_export($serviceMap, true) . ';' . PHP_EOL;
if (!is_dir(dirname($cacheFilePath))) {
mkdir(dirname($cacheFilePath), 0777);
}
file_put_contents($cacheFilePath, $cachedFile);
}
示例2: writeOrderByEnumForType
private function writeOrderByEnumForType(KalturaTypeReflector $type)
{
$map = KAutoloader::getClassMap();
if (!isset($map[$type->getType()])) {
return;
}
$this->_txt = "";
$parentType = $type;
while (1) {
$parentType = $parentType->getParentTypeReflector();
if ($parentType === null || $parentType->isFilterable()) {
break;
}
}
$partnetClassName = $parentType ? $parentType->getType() . "OrderBy" : "KalturaStringEnum";
$enumName = $type->getType() . "OrderBy";
$enumPath = dirname($map[$type->getType()]) . "/filters/orderEnums/{$enumName}.php";
$subpackage = ($type->getPackage() == 'api' ? '' : 'api.') . 'filters.enum';
$this->appendLine("<?php");
$this->appendLine("/**");
$this->appendLine(" * @package " . $type->getPackage());
$this->appendLine(" * @subpackage {$subpackage}");
$this->appendLine(" */");
$this->appendLine("class {$enumName} extends {$partnetClassName}");
$this->appendLine("{");
foreach ($type->getCurrentProperties() as $prop) {
$filters = $prop->getFilters();
foreach ($filters as $filter) {
if ($filter == "order") {
$this->appendLine("\tconst " . $this->getOrderByConst($prop->getName()) . "_ASC = \"+" . $prop->getName() . "\";");
$this->appendLine("\tconst " . $this->getOrderByConst($prop->getName()) . "_DESC = \"-" . $prop->getName() . "\";");
}
}
}
$reflectionClass = new ReflectionClass($type->getType());
if (!$type->isAbstract() && $reflectionClass->getMethod("getExtraFilters")->getDeclaringClass()->getName() === $reflectionClass->getName()) {
$extraFilters = $type->getInstance()->getExtraFilters();
if ($extraFilters) {
foreach ($extraFilters as $filterFields) {
if (!isset($filterFields["order"])) {
continue;
}
$fieldName = $filterFields["order"];
$fieldConst = $this->getOrderByConst($fieldName);
$this->appendLine("\tconst {$fieldConst}_ASC = \"+{$fieldName}\";");
$this->appendLine("\tconst {$fieldConst}_DESC = \"-{$fieldName}\";");
}
}
}
$this->appendLine("}");
$this->writeToFile($enumPath, $this->_txt);
}
示例3: initClassMap
protected function initClassMap()
{
if ($this->_classMap !== null) {
return;
}
$this->_classMap = KAutoloader::getClassMap();
}
示例4: cacheMap
static function cacheMap($servicePath, $cacheFilePath)
{
if (!is_dir($servicePath)) {
throw new Exception('Invalid directory [' . $servicePath . ']');
}
$servicePath = realpath($servicePath);
$serviceMap = array();
$classMap = KAutoloader::getClassMap();
$checkedClasses = array();
//Retrieve all service classes from the classMap.
$serviceClasses = array();
foreach ($classMap as $class => $classFilePath) {
$classFilePath = realpath($classFilePath);
if (strpos($classFilePath, $servicePath) === 0) {
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isSubclassOf('KalturaBaseService')) {
$serviceDoccomment = new KalturaDocCommentParser($reflectionClass->getDocComment());
$serviceClasses[$serviceDoccomment->serviceName] = $class;
}
}
}
//Retrieve all plugin service classes.
$pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaServices');
foreach ($pluginInstances as $pluginName => $pluginInstance) {
$pluginServices = $pluginInstance->getServicesMap();
foreach ($pluginServices as $serviceName => $serviceClass) {
$serviceName = strtolower($serviceName);
$serviceId = "{$pluginName}_{$serviceName}";
$serviceClasses[$serviceId] = $serviceClass;
}
}
//Add core & plugin services to the services map
$aliasActions = array();
foreach ($serviceClasses as $serviceId => $serviceClass) {
$serviceReflectionClass = KalturaServiceReflector::constructFromClassName($serviceClass);
$serviceMapEntry = new KalturaServiceActionItem();
$serviceMapEntry->serviceId = $serviceId;
$serviceMapEntry->serviceClass = $serviceClass;
$serviceMapEntry->serviceInfo = $serviceReflectionClass->getServiceInfo();
$actionMap = array();
$nativeActions = $serviceReflectionClass->getActions();
foreach ($nativeActions as $actionId => $actionName) {
$actionMap[strtolower($actionId)] = array("serviceClass" => $serviceClass, "actionMethodName" => $actionName, "serviceId" => $serviceId, "actionName" => $actionId);
}
$serviceMapEntry->actionMap = $actionMap;
$serviceMap[strtolower($serviceId)] = $serviceMapEntry;
foreach ($serviceReflectionClass->getAliasActions() as $alias => $methodName) {
$aliasActions[$alias] = "{$serviceId}.{$methodName}";
}
}
// add aliases
foreach ($aliasActions as $aliasAction => $sourceAction) {
list($aliasService, $aliasAction) = explode('.', $aliasAction);
list($sourceService, $sourceAction) = explode('.', $sourceAction);
$aliasService = strtolower($aliasService);
$sourceService = strtolower($sourceService);
$extServiceClass = $serviceClasses[$sourceService];
$serviceMap[$aliasService]->actionMap[strtolower($aliasAction)] = array("serviceClass" => $extServiceClass, "actionMethodName" => $sourceAction, "serviceId" => $sourceService, "actionName" => $aliasAction);
}
// filter out services that have no actions
$serviceMap = array_filter($serviceMap, array('KalturaServicesMap', 'filterEmptyServices'));
if (!is_dir(dirname($cacheFilePath))) {
mkdir(dirname($cacheFilePath));
chmod(dirname($cacheFilePath), 0755);
}
kFile::safeFilePutContents($cacheFilePath, serialize($serviceMap), 0644);
}
示例5: getClassFilePath
private function getClassFilePath($class)
{
$map = KAutoloader::getClassMap();
if (!isset($map[$class])) {
throw new Exception("File path was not found for [{$class}]");
}
return $map[$class];
}