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


PHP sfGuardGroupPeer::getDefaultGroup方法代码示例

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


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

示例1: delete

 public function delete(PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($this->isDefaultGroup()) {
         throw new sfException('Cannot remove default group (ID ' . $this->id . ')!');
         return false;
     }
     /*
      * get default group
      *
      */
     $default_group = sfGuardGroupPeer::getDefaultGroup();
     //get default group
     /*
      * check if servers has this group
      * If servers found remove reference to group to be deleted
      */
     $con->beginTransaction();
     try {
         //select from...
         $c1 = new Criteria();
         $c1->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $this->getId());
         //update set
         $c2 = new Criteria();
         $c2->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $default_group->getId());
         BasePeer::doUpdate($c1, $c2, $con);
         parent::delete($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:35,代码来源:sfGuardGroup.php

示例2: executeJsonImport


//.........这里部分代码省略.........
             $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         $etva_network = new EtvaNetwork();
         $etva_network->fromArray($network, BasePeer::TYPE_FIELDNAME);
         $collNetworks[] = $etva_network;
         $i++;
     }
     $env = new OvfEnvelope_VA();
     $env->fromArray($import_data);
     /* get server copy VA server representation */
     $params = $env->_VA();
     $method = 'vm_ovf_import_may_fork';
     $response = $etva_node->soapSend($method, $params);
     if (!$response['success']) {
         $error_decoded = $response['error'];
         $result = $response;
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_ERR_CREATE_, array('%name%' => $server['name'], '%info%' => $error_decoded));
         $result['error'] = $msg_i18n;
         //notify event log
         $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $response['info']), EtvaServerPeer::_ERR_CREATE_);
         $this->dispatcher->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     $response_decoded = (array) $response['response'];
     $returned_object = (array) $response_decoded['_obj_'];
     $returned_lvs = (array) $returned_object['LVS'];
     $collLvs = array();
     foreach ($returned_lvs as $disk) {
         $disk_array = (array) $disk;
         $vg_info = (array) $disk_array[EtvaLogicalvolume::VOLUMEGROUP_MAP];
         $vg = $vg_info[EtvaVolumegroup::VG_MAP];
         $fake_lv_response = array('success' => true, 'response' => array('_obj_' => $disk_array));
         // create logical volume
         $etva_lv = new EtvaLogicalvolume();
         $etva_lv->setEtvaVolumegroup($collVgs[$vg]);
         $lv_va = new EtvaLogicalvolume_VA($etva_lv);
         $lv_response = $lv_va->processResponse($etva_node, $fake_lv_response, 'lvcreate');
         if (!$lv_response['success']) {
             $return = $this->setJsonError($lv_response);
             return $this->renderText($return);
         }
         $collLvs[] = $etva_lv;
     }
     $etva_server = new EtvaServer();
     $etva_server->fromArray($server, BasePeer::TYPE_FIELDNAME);
     $user_groups = $this->getUser()->getGroups();
     $server_sfgroup = array_shift($user_groups);
     //if user has group then put one of them otherwise put DEFAULT GROUP ID
     if ($server_sfgroup) {
         $etva_server->setsfGuardGroup($server_sfgroup);
     } else {
         $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup());
     }
     foreach ($collNetworks as $coll) {
         $etva_server->addEtvaNetwork($coll);
     }
     $i = 0;
     foreach ($collLvs as $coll) {
         $server_disk = new EtvaServerLogical();
         $server_disk->setEtvaLogicalvolume($coll);
         $server_disk->setBootDisk($i);
         $etva_server->addEtvaServerLogical($server_disk);
         $i++;
     }
     //update some data from agent response
     $vm = (array) $returned_object['VM'];
     $etva_server->initData($vm);
     //$etva_server->setEtvaNode($etva_node);
     $etva_server->setEtvaCluster($etva_node->getEtvaCluster());
     try {
         $etva_server->save();
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg, 'info' => $msg);
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     // assign To etva_node
     $etva_server->assignTo($etva_node);
     $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_OK_CREATE_, array('%name%' => $server['name']));
     $message = Etva::getLogMessage(array('name' => $server['name']), EtvaServerPeer::_OK_CREATE_);
     $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
     $result = array('success' => true, 'agent' => $response['agent'], 'insert_id' => $etva_server->getId(), 'response' => $msg_i18n);
     $return = json_encode($result);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     // if is browser request return text renderer
     return $this->renderText($return);
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:101,代码来源:actions.class.php

示例3: buildServer

 public function buildServer($method)
 {
     $etva_server = $this->etva_server;
     if ($method == self::SERVER_CREATE) {
         $etva_server->setUuid(EtvaServerPeer::generateUUID());
         $vnc_keymap = EtvaSettingPeer::retrieveByPk('vnc_keymap');
         $etva_server->setVncKeymap($vnc_keymap->getValue());
         $user_groups = sfContext::getInstance()->getUser()->getGroups();
         $server_sfgroup = array_shift($user_groups);
         //if user has group then put one of them otherwise put DEFAULT GROUP ID
         if ($server_sfgroup) {
             $etva_server->setsfGuardGroup($server_sfgroup);
         } else {
             $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup());
         }
     }
     foreach ($this->collNetworks as $coll) {
         $etva_server->addEtvaNetwork($coll);
     }
     foreach ($this->collDisks as $coll) {
         $etva_server->addEtvaServerLogical($coll);
     }
     if (isset($this->collDevices)) {
         $str = json_encode($this->collDevices);
         $etva_server->setDevices($str);
     }
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:27,代码来源:EtvaServer_VA.class.php

示例4: executeView

 public function executeView(sfWebRequest $request)
 {
     // get default Group ID to mark as cannot delete
     $this->defaultGroupID = sfGuardGroupPeer::getDefaultGroup()->getId();
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:5,代码来源:actions.class.php


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