当前位置: 首页>>代码示例>>PHP>>正文


PHP Registry::instanceExists方法代码示例

本文整理汇总了PHP中Registry::instanceExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::instanceExists方法的具体用法?PHP Registry::instanceExists怎么用?PHP Registry::instanceExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registry的用法示例。


在下文中一共展示了Registry::instanceExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: activate

 /**
  * @name: activate
  * @description: Activates an event
  */
 public function activate($type, $filename)
 {
     $type = strtolower($type);
     $this->logger->log('DEBUG', "Activating event Type:({$type}) File:({$filename})");
     list($name, $method) = explode(".", $filename);
     if (!Registry::instanceExists($name)) {
         $this->logger->log('ERROR', "Error activating method {$filename} for event type {$type}.  Could not find instance '{$name}'.");
         return;
     }
     if ($type == "setup") {
         $eventObj = new stdClass();
         $eventObj->type = 'setup';
         $this->callEventHandler($eventObj, $filename);
     } else {
         if (in_array($type, self::$EVENT_TYPES)) {
             if (!isset($this->events[$type]) || !in_array($filename, $this->events[$type])) {
                 $this->events[$type][] = $filename;
             } else {
                 $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). Event already activated!");
             }
         } else {
             $time = $this->util->parseTime($type);
             if ($time > 0) {
                 $key = $this->getKeyForCronEvent($time, $filename);
                 if ($key === null) {
                     $this->cronevents[] = array('nextevent' => 0, 'filename' => $filename, 'time' => $time);
                 } else {
                     $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). Event already activated!");
                 }
             } else {
                 $this->logger->log('ERROR', "Error activating event Type:({$type}) File:({$filename}). The type is not a recognized event type!");
             }
         }
     }
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:39,代码来源:EventManager.class.php

示例2: register

 /**
  * @name: register
  * @description: Registers a subcommand
  */
 public function register($module, $channel, $filename, $command, $admin, $parent_command, $description = 'none', $help = '', $defaultStatus = null)
 {
     $command = strtolower($command);
     $module = strtoupper($module);
     if (!$this->chatBot->processCommandArgs($channel, $admin)) {
         $this->logger->log('ERROR', "Invalid args for {$module}:subcommand({$command})");
         return;
     }
     list($name, $method) = explode(".", $filename);
     if (!Registry::instanceExists($name)) {
         $this->logger->log('ERROR', "Error registering method {$filename} for subcommand {$command}.  Could not find instance '{$name}'.");
         return;
     }
     if ($defaultStatus === null) {
         if ($this->chatBot->vars['default_module_status'] == 1) {
             $status = 1;
         } else {
             $status = 0;
         }
     } else {
         $status = $defaultStatus;
     }
     for ($i = 0; $i < count($channel); $i++) {
         $this->logger->log('DEBUG', "Adding Subcommand to list:({$command}) File:({$filename}) Admin:({$admin}) Channel:({$channel[$i]})");
         if ($this->chatBot->existing_subcmds[$channel[$i]][$command] == true) {
             $sql = "UPDATE cmdcfg_<myname> SET `module` = ?, `verify` = ?, `file` = ?, `description` = ?, `dependson` = ?, `help` = ? WHERE `cmd` = ? AND `type` = ?";
             $this->db->exec($sql, $module, '1', $filename, $description, $parent_command, $help, $command, $channel[$i]);
         } else {
             $sql = "INSERT INTO cmdcfg_<myname> (`module`, `type`, `file`, `cmd`, `admin`, `description`, `verify`, `cmdevent`, `dependson`, `status`, `help`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
             $this->db->exec($sql, $module, $channel[$i], $filename, $command, $admin[$i], $description, '1', 'subcmd', $parent_command, $status, $help);
         }
     }
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:37,代码来源:SubcommandManager.class.php

示例3: registerInstance

 public function registerInstance($MODULE_NAME, $name, &$obj)
 {
     $name = strtolower($name);
     $this->logger->log('DEBUG', "Registering instance name '{$name}' for module '{$MODULE_NAME}'");
     if (Registry::instanceExists($name)) {
         $this->logger->log('WARN', "Instance with name '{$name}' already registered--replaced with new instance");
     }
     $obj->moduleName = $MODULE_NAME;
     Registry::setInstance($name, $obj);
     // register settings annotated on the class
     $reflection = new ReflectionAnnotatedClass($obj);
     foreach ($reflection->getProperties() as $property) {
         if ($property->hasAnnotation('Setting')) {
             $this->settingManager->add($MODULE_NAME, $property->getAnnotation('Setting')->value, $property->getAnnotation('Description')->value, $property->getAnnotation('Visibility')->value, $property->getAnnotation('Type')->value, $obj->{$property->name}, @$property->getAnnotation('Options')->value, @$property->getAnnotation('Intoptions')->value, @$property->getAnnotation('AccessLevel')->value, @$property->getAnnotation('Help')->value);
         }
     }
     // register commands, subcommands, and events annotated on the class
     $commands = array();
     $subcommands = array();
     foreach ($reflection->getAllAnnotations() as $annotation) {
         if ($annotation instanceof DefineCommand) {
             if (!$annotation->command) {
                 $this->logger->log('WARN', "Cannot parse @DefineCommand annotation in '{$name}'.");
             }
             $command = $annotation->command;
             $definition = array('channels' => $annotation->channels, 'defaultStatus' => $annotation->defaultStatus, 'accessLevel' => $annotation->accessLevel, 'description' => $annotation->description, 'help' => $annotation->help, 'handlers' => array());
             list($parentCommand, $subCommand) = explode(" ", $command, 2);
             if ($subCommand) {
                 $definition['parentCommand'] = $parentCommand;
                 $subcommands[$command] = $definition;
             } else {
                 $commands[$command] = $definition;
             }
             // register command alias if defined
             if ($annotation->alias) {
                 $this->commandAlias->register($MODULE_NAME, $command, $annotation->alias);
             }
         }
     }
     foreach ($reflection->getMethods() as $method) {
         if ($method->hasAnnotation('Setup')) {
             $this->setupHandlers[] = array($name, $method->name);
         } else {
             if ($method->hasAnnotation('HandlesCommand')) {
                 $commandName = $method->getAnnotation('HandlesCommand')->value;
                 $methodName = $method->name;
                 $handlerName = "{$name}.{$method->name}";
                 if (isset($commands[$commandName])) {
                     $commands[$commandName]['handlers'][] = $handlerName;
                 } else {
                     if (isset($subcommands[$commandName])) {
                         $subcommands[$commandName]['handlers'][] = $handlerName;
                     } else {
                         $this->logger->log('WARN', "Cannot handle command '{$commandName}' as it is not defined with @DefineCommand in '{$name}'.");
                     }
                 }
             } else {
                 if ($method->hasAnnotation('Event')) {
                     $this->eventManager->register($MODULE_NAME, $method->getAnnotation('Event')->value, $name . '.' . $method->name, @$method->getAnnotation('Description')->value, @$method->getAnnotation('Help')->value, @$method->getAnnotation('DefaultStatus')->value);
                 }
             }
         }
     }
     foreach ($commands as $command => $definition) {
         $this->commandManager->register($MODULE_NAME, $definition['channels'], implode(',', $definition['handlers']), $command, $definition['accessLevel'], $definition['description'], $definition['help'], $definition['defaultStatus']);
     }
     foreach ($subcommands as $subCommand => $definition) {
         $this->subcommandManager->register($MODULE_NAME, $definition['channels'], implode(',', $definition['handlers']), $subCommand, $definition['accessLevel'], $definition['parentCommand'], $definition['description'], $definition['help'], $definition['defaultStatus']);
     }
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:70,代码来源:Budabot.class.php

示例4: getConfigurationKey

 /**
  * Returns configuration key. This method is independent from oxConfig functionality.
  *
  * @return string
  */
 protected function getConfigurationKey()
 {
     if (Registry::instanceExists('oxConfigFile')) {
         $config = Registry::get('oxConfigFile');
     } else {
         $config = new ConfigFile(getShopBasePath() . '/config.inc.php');
         Registry::set('oxConfigFile', $config);
     }
     return $config->getVar('sConfigKey') ?: Config::DEFAULT_CONFIG_KEY;
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:15,代码来源:ModuleVariablesLocator.php

示例5: activate

 /**
  * @name: activate
  * @description: Activates a command
  */
 public function activate($channel, $filename, $command, $admin = 'all')
 {
     $command = strtolower($command);
     $admin = strtolower($admin);
     $channel = strtolower($channel);
     $this->logger->log('DEBUG', "Activate Command:({$command}) Admin Type:({$admin}) File:({$filename}) Channel:({$channel})");
     foreach (explode(',', $filename) as $handler) {
         list($name, $method) = explode(".", $handler);
         if (!Registry::instanceExists($name)) {
             $this->logger->log('ERROR', "Error activating method {$handler} for command {$command}.  Could not find instance '{$name}'.");
             return;
         }
     }
     $obj = new stdClass();
     $obj->file = $filename;
     $obj->admin = $admin;
     $this->commands[$channel][$command] = $obj;
 }
开发者ID:jibinam,项目名称:budabot2,代码行数:22,代码来源:CommandManager.class.php


注:本文中的Registry::instanceExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。