/** * build a handler from a fully qualified class name * * @param FactorySpec $spec specification for requested handler * * @return XoopsObjectHandler|null */ public function build(FactorySpec $spec) { $handler = null; $class = $spec->getName(); if (class_exists($class)) { $handler = new $class($spec->getFactory()->db()); } if ($handler === null) { if (false === $spec->getOptional()) { throw new NoHandlerException(sprintf('Class not found %s', $class)); } } return $handler; }
/** * build a module handler for legacy module * * @param FactorySpec $spec specification for requested handler * * @return XoopsObjectHandler|null */ public function build(FactorySpec $spec) { $handler = null; $name = strtolower($spec->getName()); $dirname = strtolower($spec->getDirname()); $handlerFile = \XoopsBaseConfig::get('root-path') . "/modules/{$dirname}/class/{$name}.php"; if (\XoopsLoad::fileExists($handlerFile)) { include_once $handlerFile; } $class = ucfirst($dirname) . ucfirst($name) . 'Handler'; if (class_exists($class, false)) { $handler = new $class($spec->getFactory()->db()); } if ($handler === null) { if (false === $spec->getOptional()) { throw new NoHandlerException(sprintf('Class not found %s', $class)); } } return $handler; }
/** * build a kernel handler * * @param FactorySpec $spec specification for requested handler * * @return XoopsObjectHandler|null */ public function build(FactorySpec $spec) { $handler = null; $specName = strtolower($spec->getName()); if (!isset($this->lookupTable[$specName])) { if (false === $spec->getOptional()) { throw new NoHandlerException(sprintf('Unknown handler %s', $specName)); } return $handler; } $name = $this->lookupTable[$specName]; $class = '\\Xoops\\Core\\Kernel\\Handlers\\Xoops' . $name . 'Handler'; if (class_exists($class)) { $handler = new $class($spec->getFactory()->db()); } if ($handler === null) { if (false === $spec->getOptional()) { throw new NoHandlerException(sprintf('Class not found %s', $class)); } } return $handler; }