コード例 #1
0
ファイル: FQN.php プロジェクト: ming-hai/XoopsCore
 /**
  * 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;
 }
コード例 #2
0
ファイル: LegacyModule.php プロジェクト: ming-hai/XoopsCore
 /**
  * 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;
 }
コード例 #3
0
ファイル: Kernel.php プロジェクト: ming-hai/XoopsCore
 /**
  * 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;
 }
コード例 #4
0
ファイル: Factory.php プロジェクト: ming-hai/XoopsCore
 /**
  * @param FactorySpec $spec specification
  * @return SchemeInterface
  */
 private function getSchemeObject(FactorySpec $spec)
 {
     $schemeName = $this->schemes[$spec->getScheme()];
     $scheme = null;
     if (class_exists($schemeName)) {
         $scheme = new $schemeName();
     }
     if (!$scheme instanceof SchemeInterface) {
         throw new InvalidHandlerSpecException(sprintf('Unknown scheme %s', $schemeName));
     }
     return $scheme;
 }