示例#1
0
/**
 * @deprecated
 * @param string $name
 * @param mixed $optional
 * @return XoopsObjectHandler|XoopsPersistableObjectHandler|null
 */
function xoops_getHandler($name, $optional = false)
{
    $xoops = Xoops::getInstance();
    $xoops->deprecated('xoops_getHandler(\'' . $name . '\') is deprecated. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__);
    $handler = Factory::newSpec()->scheme('kernel')->name($name)->optional((bool) $optional)->build();
    return $handler;
}
示例#2
0
 /**
  * @covers Xoops\Core\Handler\Factory::build
  */
 public function testBuild_optional()
 {
     $spec = $this->object->newSpec()->scheme('kernel')->name('nosuchhandler')->optional(true);
     $handler = $this->object->build($spec);
     $this->assertNull($handler);
     $spec = $this->object->newSpec()->scheme('kernel')->name('user')->optional(false);
     $handler = $this->object->build($spec);
     $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\Handlers\\XoopsUserHandler', $handler);
 }
示例#3
0
 /**
  * Get handler
  *
  * @param string  $name     name of handler
  * @param boolean $optional true if failure to load handler should be considered a warning, not an error
  *
  * @return XoopsObjectHandler|XoopsPersistableObjectHandler|null
  */
 protected function getHandler($name, $optional = false)
 {
     if (!isset($this->kernelHandlers[$name])) {
         if (!isset($this->handlerFactory)) {
             $this->handlerFactory = HandlerFactory::getInstance();
         }
         $handler = $this->handlerFactory->newSpec()->scheme('kernel')->name($name)->optional($optional)->build();
         if ($handler === null) {
             $this->logger()->log(\Psr\Log\LogLevel::WARNING, sprintf('A handler for %s is not available', $name));
         }
         $this->kernelHandlers[$name] = $handler;
     }
     return $this->kernelHandlers[$name];
 }
示例#4
0
 /**
  * Initialize parent::__constuct calls this after verifying module object.
  *
  * @return void
  */
 public function init()
 {
     $this->mid = $this->module->getVar('mid');
     $this->dirname = $this->module->getVar('dirname');
     $this->permissionHandler = Factory::newSpec()->scheme('kernel')->name('groupperm')->build();
 }