本文整理汇总了PHP中Application::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::factory方法的具体用法?PHP Application::factory怎么用?PHP Application::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::factory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldObject
/**
* Returns the field object.
*
* @return Bengine_Game_Profile_Field_Abstract
*/
public function getFieldObject()
{
if (!$this->exists("field_object")) {
$field = Application::factory("game/profile_field_" . strtolower($this->getType()), $this);
$field->setData($this->getData());
$this->set("field_object", $field);
}
return $this->get("field_object");
}
示例2: getHandlerObject
/**
* Retrieves the handler object of the code or the mode.
*
* @param string|integer $code
* @param Bengine_Game_Model_Event $event
* @throws Recipe_Exception_Generic
* @return Bengine_Game_EventHandler_Handler_Abstract
*/
public static function getHandlerObject($code, Bengine_Game_Model_Event $event = null)
{
$handler = self::translateCode($code);
list($package, $class) = explode("/", $handler->get("code"));
$class = $package . "/eventHandler_handler_" . $handler->get("base_type") . "_" . $class;
if ($handlerObj = Application::factory($class, $event)) {
return $handlerObj;
}
throw new Recipe_Exception_Generic("Unable to instantiate handler code '" . $code . "'.");
}
示例3: getRewardObject
/**
* @return Bengine_Game_Achievement_Reward_Abstract
* @throws Recipe_Exception_Generic
*/
public function getRewardObject()
{
if (!$this->exists("reward_object")) {
/* @var Bengine_Game_Achievement_Reward_Abstract $object */
$object = Application::factory($this->get("class"), null);
if (!$object) {
throw new Recipe_Exception_Generic("Unknown achievement reward '{$this->get("class")}'.");
}
$object->setValue($this->get("value"));
$object->setType($this->get("type"));
$this->set("reward_object", $object);
}
return $this->get("reward_object");
}
示例4: exeCron
/**
* Search in database for expired cron tasks and execute them.
*
* @throws Recipe_Exception_Generic
* @return Recipe_Cron
*/
public function exeCron()
{
$select = array("cronid", "class", "month", "day", "weekday", "hour", "minute", "xtime", "active");
$_result = Core::getQuery()->select("cronjob", $select, "", "(xtime <= " . TIME . " OR xtime IS NULL) AND active = '1'");
foreach ($_result->fetchAll() as $_row) {
$class = explode("/", $_row["class"]);
$class = $class[0] . "/cronjob_" . $class[1];
$cronjobObj = Application::factory($class);
if ($cronjobObj instanceof Recipe_CronjobAbstract) {
Hook::event("ExecuteCronjob", array($this, &$_row, $cronjobObj));
$cronjobObj->execute($_row["cronid"], $_row["xtime"], $this->calcNextExeTime($_row));
} else {
throw new Recipe_Exception_Generic("Cannot execute cron job \"{$_row["class"]}\".");
}
}
$_result->closeCursor();
return $this;
}
示例5: getRequirementObject
/**
* @return Bengine_Game_Achievement_Requirement_Abstract
*/
public function getRequirementObject()
{
if (!$this->exists("requirement_object")) {
/* @var Bengine_Game_Achievement_Requirement_Abstract $object */
$object = Application::factory($this->get("class"), null);
if (!$object) {
throw new Recipe_Exception_Generic("Unknown achievement requirement '{$this->get("class")}'.");
}
$object->setValue($this->get("value"));
$object->setId($this->get("id"));
$config = $this->get("config");
if (!empty($config)) {
$config = @json_decode($config, true);
if (false === $config) {
$config = @unserialize($config);
}
}
if (is_array($config)) {
$object->setConfig($config);
}
$this->set("requirement_object", $object);
}
return $this->get("requirement_object");
}
示例6: readFolderAction
/**
* Shows content of a message folder.
*
* @param integer $id Folder id
*
* @return Bengine_Game_Controller_MSG
*/
protected function readFolderAction($id)
{
if ($this->isPost()) {
$this->deleteMessages($id, $this->getParam("deleteOption"), $this->getParam("msgid", array()));
}
$pagination = $this->getPagination($id);
$pagination->render();
$readMessages = array();
/* @var Bengine_Game_Model_Collection_Message $messages */
$messages = Game::getCollection("game/message");
$messages->addTimeOrder()->addFolderJoin()->addReceiverFilter(Core::getUser()->get("userid"))->addFolderFilter($id)->setPagination($pagination);
$folderObjCache = array();
/* @var Bengine_Game_Model_Message $message */
foreach ($messages as $message) {
Hook::event("ReadMessageFirst", array($message));
$folderCode = $message->get("folder_class");
if (!isset($folderObjCache[$folderCode])) {
$folderClass = explode("/", $folderCode);
$folderClass = $folderClass[0] . "/messageFolder_" . $folderClass[1];
$folderObj = Application::factory($folderClass);
$folderObjCache[$folderCode] = $folderObj;
} else {
$folderObj = $folderObjCache[$folderCode];
}
$folderObj->formatMessage($message);
if (!$message->get("read")) {
$readMessages[] = (int) $message->get("msgid");
}
Hook::event("ReadMessageLast", array($message));
}
if (count($readMessages) > 0) {
Core::getQuery()->update("message", array("read" => 1), "msgid = " . implode(" OR msgid = ", $readMessages));
}
Core::getTPL()->addLoop("messages", $messages);
Core::getTPL()->assign("mode", $id);
Core::getTPL()->assign("pagination", $pagination);
return $this;
}
示例7: getItems
/**
* Returns the last messages for the user.
*
* @param integer $offset
* @param integer $count
*
* @return array
*/
protected function getItems($offset, $count)
{
$folderClassCache = array();
$items = array();
/* @var Bengine_Game_Model_Collection_Message $messages */
$messages = Comm::getCollection("game/message");
$messages->addTimeOrder()->addReceiverFilter($this->user_id)->addFolderJoin();
$select = $messages->getSelect();
$select->limit($offset, $count);
$select->where("m.mode != ?", self::OUTBOX_FOLDER_ID);
/* @var Bengine_Game_Model_Message $message */
foreach ($messages as $message) {
/* @var Bengine_Game_MessageFolder_Abstract $folderObj */
$folderCode = $message->get("folder_class");
if (!isset($folderClassCache[$folderCode])) {
$folderClass = explode("/", $folderCode);
$folderClass = $folderClass[0] . "/messageFolder_" . $folderClass[1];
$folderObj = Application::factory($folderClass);
$folderClassCache[$folderCode] = $folderObj;
} else {
$folderObj = $folderClassCache[$folderCode];
}
$folderObj->formatMessage($message, true);
$items[] = array("date" => Date::timeToString(3, $message->getTime(), "D, d M Y H:i:s O", false), "author" => $message->get("username") ? $message->get("username") : "System", "title" => strip_tags($message->get("subject")), "text" => $message->get("message"), "link" => $message->get("link"), "date_atom" => Date::timeToString(3, $message->getTime(), "c", false), "guid" => $message->getId());
}
return $items;
}