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


PHP Relationship::switchEntityOrderIfNecessary方法代码示例

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


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

示例1: executeAddRelationshipCategory

 public function executeAddRelationshipCategory($request)
 {
     $this->checkEntity($request, false, false);
     $this->entity2 = Doctrine::getTable('Entity')->find($request->getParameter('entity2_id'));
     $this->forward404Unless($this->entity2);
     $ext1 = $this->entity->getPrimaryExtension();
     $ext2 = $this->entity2->getPrimaryExtension();
     $this->categories = RelationshipCategoryTable::getByExtensionsQuery($ext1, $ext2)->execute();
     $this->reference_form = new ReferenceForm();
     $rel = new Relationship();
     $rel->Entity1 = $this->entity;
     $rel->Entity2 = $this->entity2;
     $this->reference_form->setSelectObject($rel);
     if ($request->isMethod('post')) {
         $refParams = $request->getParameter('reference');
         $this->reference_form->bind($refParams);
         if ($this->reference_form->isValid()) {
             //lobbying will need to be handled seperately
             if ($request->getParameter('category_id') == RelationshipTable::LOBBYING_CATEGORY) {
                 switch ($request->getParameter('lobbying_scenario')) {
                     case 'direct':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity;
                         $r->Entity2 = $this->entity2;
                         $r->setCategory('Lobbying');
                         break;
                     case 'direct_reverse':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity2;
                         $r->Entity2 = $this->entity;
                         $r->setCategory('Lobbying');
                         break;
                     case 'service':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity;
                         $r->Entity2 = $this->entity2;
                         $r->setCategory('Transaction');
                         $r->description1 = 'Lobbying Client';
                         $r->description2 = $this->entity2['primary_ext'] == 'Org' ? 'Lobbying Firm' : 'Lobbyist';
                         break;
                     case 'service_reverse':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity2;
                         $r->Entity2 = $this->entity;
                         $r->setCategory('Transaction');
                         $r->description1 = 'Lobbying Client';
                         $r->description2 = $this->entity['primary_ext'] == 'Org' ? 'Lobbying Firm' : 'Lobbyist';
                         break;
                     default:
                         $request->setError('lobbying_scenario', "You must pick a type of lobbying relationship to create");
                         return sfView::SUCCESS;
                         break;
                 }
                 $r->saveWithRequiredReference($refParams);
                 LsCache::clearRelationshipCacheById($r->id);
                 $this->redirect($r->getInternalUrl('edit', array('ref' => 'auto')));
             }
             if ($category = Doctrine::getTable('RelationshipCategory')->find($request->getParameter('category_id'))) {
                 //save relationship and reference
                 $r = new Relationship();
                 $r->Entity1 = $this->entity;
                 $r->Entity2 = $this->entity2;
                 $r->setCategory($category->name);
                 $r->switchEntityOrderIfNecessary();
                 $r->saveWithRequiredReference($refParams);
                 LsCache::clearRelationshipCacheById($r->id);
                 //redirect to edit page
                 $this->redirect($r->getInternalUrl('edit', array('ref' => 'auto')));
             } else {
                 $request->setError('category_id', "You must select a category");
             }
         } else {
             if (!($categoryId = $request->getParameter('category_id'))) {
                 $request->setError('category_id', "You must select a category");
             }
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:78,代码来源:actions.class.php


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