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


PHP CM_Params::factory方法代码示例

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


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

示例1: _processView

 protected function _processView(array $output)
 {
     $success = array();
     $query = $this->_request->getQuery();
     if (!isset($query['method'])) {
         throw new CM_Exception_Invalid('No method specified', CM_Exception::WARN);
     }
     if (!preg_match('/^[\\w_]+$/i', $query['method'])) {
         throw new CM_Exception_Invalid('Illegal method', CM_Exception::WARN, ['method' => $query['method']]);
     }
     if (!isset($query['params']) || !is_array($query['params'])) {
         throw new CM_Exception_Invalid('Illegal params', CM_Exception::WARN);
     }
     $view = $this->_getView();
     if ($view instanceof CM_View_CheckAccessibleInterface) {
         $view->checkAccessible($this->getRender()->getEnvironment());
     }
     $ajaxMethodName = 'ajax_' . $query['method'];
     $params = CM_Params::factory($query['params'], true);
     $componentHandler = new CM_Frontend_JavascriptContainer_View();
     $this->_setStringRepresentation(get_class($view) . '::' . $ajaxMethodName);
     if (!method_exists($view, $ajaxMethodName)) {
         throw new CM_Exception_Invalid('Method not found', CM_Exception::WARN, ['method' => $ajaxMethodName]);
     }
     $data = $view->{$ajaxMethodName}($params, $componentHandler, $this);
     $success['data'] = CM_Params::encode($data);
     $frontend = $this->getRender()->getGlobalResponse();
     $frontend->getOnloadReadyJs()->append($componentHandler->compile('this'));
     $jsCode = $frontend->getJs();
     if (strlen($jsCode)) {
         $success['exec'] = $jsCode;
     }
     $output['success'] = $success;
     return $output;
 }
开发者ID:cargomedia,项目名称:cm,代码行数:35,代码来源:Ajax.php

示例2: __construct

 /**
  * @param CM_Params|array|null $params
  */
 public function __construct($params = null)
 {
     if (!$params instanceof CM_Params) {
         $params = CM_Params::factory($params, false);
     }
     $this->_params = $params;
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:10,代码来源:Abstract.php

示例3: smarty_function_formField

function smarty_function_formField(array $params, Smarty_Internal_Template $template)
{
    /** @var CM_Frontend_Render $render */
    $render = $template->smarty->getTemplateVars('render');
    $cssClasses = array();
    if (isset($params['class'])) {
        $cssClasses[] = (string) $params['class'];
        unset($params['class']);
    }
    $label = null;
    if (isset($params['label'])) {
        $label = (string) $params['label'];
    }
    $input = null;
    $fieldName = null;
    if (isset($params['prepend'])) {
        $input .= (string) $params['prepend'];
    }
    /** @var CM_Frontend_ViewResponse|null $viewResponse */
    $viewResponse = null;
    if (isset($params['name'])) {
        $fieldName = (string) $params['name'];
        $cssClasses[] = $fieldName;
        /** @var CM_Form_Abstract $form */
        $form = $render->getGlobalResponse()->getClosestViewResponse('CM_Form_Abstract')->getView();
        if (null === $form) {
            throw new CM_Exception_Invalid('Cannot find parent `CM_Form_Abstract` view response. Named {formField} can be only rendered within form view.');
        }
        $formField = $form->getField($fieldName);
        $renderAdapter = new CM_RenderAdapter_FormField($render, $formField);
        $input .= $renderAdapter->fetch(CM_Params::factory($params, false), $viewResponse);
        if (null !== $formField->getValue()) {
            $cssClasses[] = 'prefilled';
        }
    }
    if (isset($params['append'])) {
        $input .= (string) $params['append'];
    }
    $html = '<div class="formField clearfix ' . join(' ', $cssClasses) . '">';
    if ($label) {
        $html .= '<label';
        if ($viewResponse) {
            $html .= ' for="' . $viewResponse->getAutoIdTagged('input') . '"';
        }
        $html .= '>' . $label . '</label>';
    }
    if ($input) {
        $html .= '<div class="input">';
        $html .= $input;
        $html .= '</div>';
    }
    $html .= '</div>';
    return $html;
}
开发者ID:cargomedia,项目名称:cm,代码行数:54,代码来源:function.formField.php

示例4: _process

 protected function _process()
 {
     $params = CM_Params::factory($this->_request->getQuery(), true);
     try {
         $user = $params->getUser('user');
         $mailType = $params->getInt('mailType');
         $action = new CM_Action_Email(CM_Action_Abstract::VIEW, $user, $mailType);
         $action->prepare();
         $action->notify($user, $mailType);
     } catch (CM_Exception $e) {
         if (in_array(get_class($e), ['CM_Exception_Nonexistent', 'CM_Exception_InvalidParam'])) {
             $e->setSeverity(CM_Exception::WARN);
         }
         throw $e;
     }
     $this->setHeader('Content-Type', 'image/gif');
     $this->_setContent(base64_decode('R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:18,代码来源:EmailTracking.php

示例5: smarty_function_input

function smarty_function_input(array $params, Smarty_Internal_Template $template)
{
    $params = CM_Params::factory($params, false);
    if (!$params->has('name')) {
        throw new CM_Exception_Invalid('Param `name` missing');
    }
    /** @var CM_Frontend_Render $render */
    $render = $template->smarty->getTemplateVars('render');
    /** @var CM_Form_Abstract $form */
    $form = $render->getGlobalResponse()->getClosestViewResponse('CM_Form_Abstract')->getView();
    if (null === $form) {
        throw new CM_Exception_Invalid('Cannot find parent `CM_Form_Abstract` view response. {input} can be only rendered within form view.');
    }
    $fieldName = $params->getString('name');
    $field = $form->getField($fieldName);
    $renderAdapter = new CM_RenderAdapter_FormField($render, $field);
    return $renderAdapter->fetch($params);
}
开发者ID:cargomedia,项目名称:cm,代码行数:18,代码来源:function.input.php

示例6: _process

 protected function _process()
 {
     $output = array();
     $this->_runWithCatching(function () use(&$output) {
         $query = CM_Params::factory($this->_request->getQuery());
         $method = $query->getString('method');
         if (!preg_match('/^(?<class>[\\w_]+)\\.(?<function>[\\w_]+)$/', $method, $matches)) {
             throw new CM_Exception_InvalidParam('Illegal method: `' . $method . '`.');
         }
         $class = $matches['class'];
         $function = $matches['function'];
         $params = $query->getArray('params');
         $output['success'] = array('result' => call_user_func_array(array($class, 'rpc_' . $function), $params));
     }, function (CM_Exception $e) use(&$output) {
         $output['error'] = array('type' => get_class($e), 'msg' => $e->getMessagePublic($this->getRender()), 'isPublic' => $e->isPublic());
     });
     $this->setHeader('Content-Type', 'application/json');
     $this->_setContent(json_encode($output));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:19,代码来源:RPC.php

示例7: rpc_subscribe

 /**
  * @param string $serverKey
  * @param string $sessionData
  * @param string $channelKey
  * @param string $channelMediaId
  * @param string $channelData
  * @param string $streamKey
  * @param int    $streamStart
  * @throws CM_Exception_AuthFailed
  * @throws CM_Exception_AuthRequired
  * @throws CM_Exception_Invalid
  * @throws CM_Exception_NotAllowed
  */
 public static function rpc_subscribe($serverKey, $sessionData, $channelKey, $channelMediaId, $channelData, $streamKey, $streamStart)
 {
     $janus = CM_Service_Manager::getInstance()->getJanus('janus');
     self::_authenticate($janus, $serverKey);
     $server = $janus->getServerList()->findByKey($serverKey);
     $sessionParams = CM_Params::factory(CM_Params::jsonDecode($sessionData), true);
     $session = $sessionParams->getSession('sessionId');
     $user = $session->getUser(true);
     $channelKey = (string) $channelKey;
     $channelMediaId = (string) $channelMediaId;
     $channelParams = CM_Params::factory(CM_Params::jsonDecode($channelData), true);
     $channelType = $channelParams->getInt('streamChannelType');
     $streamKey = (string) $streamKey;
     $streamStart = (int) $streamStart;
     $streamRepository = $janus->getStreamRepository();
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = $streamRepository->findStreamChannelByKey($channelKey);
     if (null === $streamChannel) {
         $streamChannel = $streamRepository->createStreamChannel($channelKey, $channelType, $server->getId(), $channelMediaId);
     } else {
         $channelServerData = ['type' => $streamChannel->getType(), 'mediaId' => $streamChannel->getMediaId(), 'serverId' => $streamChannel->getServerId()];
         $channelRequestData = ['type' => $channelType, 'mediaId' => $channelMediaId, 'serverId' => $server->getId()];
         if ($channelServerData !== $channelRequestData) {
             throw new CM_Exception_Invalid('Channel request data differs from server data', null, ['channelRequestData' => $channelRequestData, 'channelServerData' => $channelServerData]);
         }
     }
     try {
         $streamRepository->createStreamSubscribe($streamChannel, $user, $streamKey, $streamStart);
     } catch (CM_Exception_NotAllowed $exception) {
         if (!$streamChannel->hasStreams()) {
             $streamChannel->delete();
         }
         throw new CM_Exception_NotAllowed('Cannot subscribe', $exception->getSeverity(), ['originalExceptionMessage' => $exception->getMessage()]);
     } catch (CM_Exception_Invalid $exception) {
         if (!$streamChannel->hasStreams()) {
             $streamChannel->delete();
         }
         throw new CM_Exception_Invalid('Cannot subscribe', $exception->getSeverity(), ['originalExceptionMessage' => $exception->getMessage()]);
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:53,代码来源:RpcEndpoints.php

示例8: smarty_block_form

function smarty_block_form($params, $content, Smarty_Internal_Template $template, $open)
{
    /** @var CM_Frontend_Render $render */
    $render = $template->smarty->getTemplateVars('render');
    $frontend = $render->getGlobalResponse();
    if ($open) {
        $form = CM_Form_Abstract::factory($params['name'], $params);
        $viewResponse = new CM_Frontend_ViewResponse($form);
        $form->prepare($render->getEnvironment(), $viewResponse);
        $frontend->treeExpand($viewResponse);
        return '';
    } else {
        $viewResponse = $frontend->getClosestViewResponse('CM_Form_Abstract');
        if (null === $viewResponse) {
            throw new CM_Exception_Invalid('Cannot find `CM_Form_Abstract` within frontend tree.');
        }
        /** @var CM_Form_Abstract $form */
        $form = $viewResponse->getView();
        $cssClasses = $viewResponse->getCssClasses();
        $cssClasses[] = $form->getName();
        $html = '<form id="' . $viewResponse->getAutoId() . '" class="' . implode(' ', $cssClasses) . '" method="post" action="" onsubmit="return false;" novalidate >';
        if ($form->getAvoidPasswordManager()) {
            $html .= '<input style="display:none" type="text" name="fakeusernameremembered">';
            $html .= '<input style="display:none" type="password" name="fakepasswordremembered">';
        }
        $html .= $content;
        foreach ($form->getFields() as $field) {
            if ($field instanceof CM_FormField_Hidden) {
                $renderAdapter = new CM_RenderAdapter_FormField($render, $field);
                $html .= $renderAdapter->fetch(CM_Params::factory());
            }
        }
        foreach ($form->getActions() as $actionName => $action) {
            $viewResponse->getJs()->append("this.registerAction('{$actionName}', {$action->js_presentation()});");
        }
        $html .= '</form>';
        $frontend->treeCollapse();
        return $html;
    }
}
开发者ID:cargomedia,项目名称:cm,代码行数:40,代码来源:block.form.php

示例9: subscribe

 /**
  * @param string $streamName
  * @param string $clientKey
  * @param int    $start
  * @param string $data
  * @throws CM_Exception_NotAllowed
  */
 public function subscribe($streamName, $clientKey, $start, $data)
 {
     $streamName = (string) $streamName;
     $clientKey = (string) $clientKey;
     $start = (int) $start;
     $data = (string) $data;
     $user = null;
     $params = CM_Params::factory(CM_Params::jsonDecode($data), true);
     if ($params->has('sessionId')) {
         if ($session = CM_Session::findById($params->getString('sessionId'))) {
             $user = $session->getUser(false);
         }
     }
     /** @var CM_Model_StreamChannel_Abstract $streamChannel */
     $streamChannel = CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($streamName, $this->getType());
     if (!$streamChannel) {
         throw new CM_Exception_NotAllowed();
     }
     try {
         CM_Model_Stream_Subscribe::createStatic(array('streamChannel' => $streamChannel, 'user' => $user, 'start' => $start, 'key' => $clientKey));
     } catch (CM_Exception $ex) {
         throw new CM_Exception_NotAllowed('Cannot subscribe: ' . $ex->getMessage());
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:31,代码来源:Abstract.php

示例10: _getView

 /**
  * @param string|null $className
  * @return CM_View_Abstract
  */
 protected function _getView($className = null)
 {
     if (null === $className) {
         $className = 'CM_View_Abstract';
     }
     $viewInfo = $this->_getViewInfo($className);
     /** @var CM_View_Abstract $className */
     return $className::factory($viewInfo['className'], CM_Params::factory($viewInfo['params'], true));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:13,代码来源:Abstract.php

示例11: getParams

 /**
  * @param string         $key
  * @param CM_Params|null $default
  * @return CM_Params
  * @throws CM_Exception_Invalid
  */
 public function getParams($key, CM_Params $default = null)
 {
     $param = $this->getObject($key, 'CM_Params', $default, function ($className, $param) {
         if (is_string($param)) {
             $json = (string) $param;
             try {
                 $array = CM_Params::decode($json, true);
             } catch (CM_Exception_Invalid $e) {
                 throw new CM_Exception_InvalidParam('Cannot decode input', null, ['message' => $e->getMessage()]);
             }
         } elseif (is_array($param)) {
             $array = $param;
         } else {
             throw new CM_Exception_InvalidParam('Unexpected type of arguments', null, ['type' => gettype($param)]);
         }
         return CM_Params::factory($array, false);
     });
     if (!$param instanceof CM_Params) {
         throw new CM_Exception_Invalid('Not a CM_Params');
     }
     return $param;
 }
开发者ID:cargomedia,项目名称:cm,代码行数:28,代码来源:Params.php

示例12: createPage

 /**
  * @param string             $pageClass
  * @param CM_Model_User|null $viewer OPTIONAL
  * @param array              $params OPTIONAL
  * @return CM_Page_Abstract
  */
 public static function createPage($pageClass, CM_Model_User $viewer = null, $params = array())
 {
     $request = new CM_Http_Request_Get('?' . http_build_query($params), array(), $viewer);
     return new $pageClass(CM_Params::factory($request->getQuery(), true), $request->getViewer());
 }
开发者ID:aladin1394,项目名称:CM,代码行数:11,代码来源:TH.php

示例13: onRedisMessage

 /**
  * @param string $message
  * @throws CM_Exception_Invalid
  */
 public function onRedisMessage($message)
 {
     $message = CM_Params::jsonDecode($message);
     $type = $message['type'];
     $data = $message['data'];
     switch ($type) {
         case 'subscribe':
             $channel = $data['channel'];
             $clientKey = $data['clientKey'];
             $start = time();
             $data = CM_Params::factory((array) $data['data'], true);
             $user = null;
             if ($data->has('sessionId')) {
                 if ($session = CM_Session::findById($data->getString('sessionId'))) {
                     $user = $session->getUser(false);
                 }
             }
             $this->_subscribe($channel, $clientKey, $start, $user);
             break;
         case 'unsubscribe':
             $channel = $data['channel'];
             $clientKey = $data['clientKey'];
             $this->_unsubscribe($channel, $clientKey);
             break;
         case 'message':
             break;
         default:
             throw new CM_Exception_Invalid('Invalid socket-redis event type');
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:34,代码来源:SocketRedis.php

示例14: _processPage

 /**
  * @param CM_Http_Request_Abstract $request
  * @throws CM_Exception_Nonexistent
  * @throws CM_Exception
  * @throws CM_Exception_Nonexistent
  * @return string|null|boolean
  */
 private function _processPage(CM_Http_Request_Abstract $request)
 {
     return $this->_runWithCatching(function () use($request) {
         $this->getSite()->rewrite($request);
         $pageParams = CM_Params::factory($request->getQuery(), true);
         try {
             $className = CM_Page_Abstract::getClassnameByPath($this->getRender(), $request->getPath());
             $page = CM_Page_Abstract::factory($className, $pageParams);
         } catch (CM_Exception $ex) {
             throw new CM_Exception_Nonexistent('Cannot load page `' . $request->getPath() . '`: ' . $ex->getMessage());
         }
         $this->_setStringRepresentation(get_class($page));
         $page->prepareResponse($this->getRender()->getEnvironment(), $this);
         if ($this->getRedirectUrl()) {
             $request->setUri($this->getRedirectUrl());
             return null;
         }
         $html = $this->_renderPage($page);
         $this->_page = $page;
         $this->_pageParams = $pageParams;
         return $html;
     }, function (CM_Exception $ex, array $errorOptions) use($request) {
         $this->getRender()->getGlobalResponse()->clear();
         /** @var CM_Page_Abstract $errorPage */
         $errorPage = $errorOptions['errorPage'];
         $request->setPath($errorPage::getPath());
         $request->setQuery(array());
         return false;
     });
 }
开发者ID:aladin1394,项目名称:CM,代码行数:37,代码来源:Page.php

示例15: _renderFormField

 /**
  * @param CM_FormField_Abstract   $formField
  * @param array|null              $renderParams
  * @param CM_Frontend_Render|null $render
  * @return CM_Dom_NodeList
  */
 protected function _renderFormField(CM_FormField_Abstract $formField, array $renderParams = null, CM_Frontend_Render $render = null)
 {
     if (null === $render) {
         $render = new CM_Frontend_Render();
     }
     $renderAdapter = new CM_RenderAdapter_FormField($render, $formField);
     $html = $renderAdapter->fetch(CM_Params::factory($renderParams, false));
     return new CM_Dom_NodeList($html, true);
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:15,代码来源:TestCase.php


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