Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. <?php
  2. class MainTestController extends Controller
  3. {
  4. /** @var \F6S\Crm\Service\OrganizationsService $orgService */
  5. private $orgService;
  6. /** @var \F6S\Crm\Service\TeamsService $teamService */
  7. private $teamService;
  8. /** @var \F6S\Crm\Service\OrganizationMemberAppService $orgMemberAppService */
  9. private $orgMemberAppService;
  10. /** @var \F6S\Crm\Service\PipelinesService $pipelineService */
  11. private $pipelineService;
  12. /** @var \F6S\Crm\Service\TeamMemberService $teamMemberService */
  13. private $teamMemberService;
  14. private $actorId;
  15.  
  16. public function onDispatch()
  17. {
  18. $this->orgService = $this->getService(\F6S\Crm\Service\OrganizationsService::class);
  19. $this->teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
  20. $this->orgMemberAppService = $this->getService(\F6S\Crm\Service\OrganizationMemberAppService::class);
  21. $this->pipelineService = $this->getService(\F6S\Crm\Service\PipelinesService::class);
  22. $this->teamMemberService = $this->getService(\F6S\Crm\Service\TeamMemberService::class);
  23. $this->actorId = $this->top->collector->me->info['actor_id'];
  24. }
  25.  
  26. public function truncateAll()
  27. {
  28. $tables = [
  29. 'acl_resources',
  30. 'acl_resource_permissions',
  31. 'acl_roles',
  32. 'acl_user_roles',
  33. 'crm_organizations',
  34. 'crm_people_to_organization',
  35. 'crm_teams',
  36. 'crm_people_to_team',
  37. 'crm_pipelines',
  38. 'crm_pipeline_owners',
  39. ];
  40.  
  41. foreach ($tables as $table) {
  42. $query = "TRUNCATE TABLE `$table`";
  43. pr($query);
  44. $this->top->db->execute($query);
  45. }
  46. }
  47.  
  48. public function addOrganization()
  49. {
  50. $name = 'Radu org ' . uniqid();
  51.  
  52. $command = new \F6S\Crm\Command\AddOrganization($name, $this->actorId);
  53. $handler = $this->getService(\F6S\Crm\CommandHandler\AddOrganizationHandler::class);
  54. $handler->handle($command);
  55.  
  56. pr($command->getResult());
  57. }
  58.  
  59. public function addMemberToOrganization()
  60. {
  61. $actorId = 666;
  62. $orgId = 5;
  63. $addOrganizationMemberHandler = $this->getService(\F6S\Crm\CommandHandler\AddOrganizationMemberHandler::class);
  64.  
  65. $command = new \F6S\Crm\Command\AddOrganizationMember($actorId, $orgId);
  66. $addOrganizationMemberHandler->handle($command);
  67.  
  68. pr($command->getResult());
  69. }
  70.  
  71. public function updateMember()
  72. {
  73. $actorId = 7776;
  74. $orgId = 2;
  75. $position = null;
  76. $group = 'SW 20182';
  77.  
  78. $command = new \F6S\Crm\Command\UpdateOrganizationMember($actorId, $orgId, $position, $group);
  79. $handler = $this->getService(\F6S\Crm\CommandHandler\UpdateOrganizationMemberHandler::class);
  80. $handler->handle($command);
  81.  
  82. pr($command->getResult());
  83. }
  84.  
  85. public function getOrganizationMembers()
  86. {
  87. $orgId = 2;
  88. $members = $this->orgService->findMembers($orgId);
  89. pr($members);
  90. }
  91.  
  92. public function addTeam()
  93. {
  94. $name = 'Test Team 6';
  95. $organizationId = 2;
  96. $description = 'team description';
  97.  
  98. $command = new \F6S\Crm\Command\AddTeam($name, $organizationId, $this->actorId, $description);
  99. $handler = $this->getService(\F6S\Crm\CommandHandler\AddTeamHandler::class);
  100. $handler->handle($command);
  101.  
  102. pr($command->getResult());
  103. }
  104.  
  105. public function findTeam()
  106. {
  107. $teamId = 9;
  108. $team = $this->teamService->findTeam($teamId);
  109. pr($team);
  110. }
  111.  
  112. public function findMembers()
  113. {
  114. $teamId = 1;
  115. $members = $this->teamMemberService->findTeamMembers($teamId);
  116. pr($members);
  117. }
  118.  
  119. public function findOrganizationTeams()
  120. {
  121. // FAILED
  122. $orgId = 2;
  123. $teams = $this->teamService->findOrganizationTeams($orgId);
  124.  
  125. $results = [];
  126. foreach ($teams as $team) {
  127. $results[] = $team;
  128. }
  129.  
  130. pr($results);
  131. }
  132.  
  133. public function addMemberToTeam()
  134. {
  135. $actorId = 1009;
  136. $teamId = 4;
  137.  
  138. $command = new \F6S\Crm\Command\AddMemberToTeam($actorId, $teamId);
  139. $handler = $this->getService(\F6S\Crm\CommandHandler\AddMemberToTeamHandler::class);
  140. $handler->handle($command);
  141. }
  142.  
  143. public function deleteMemberFromOrganization()
  144. {
  145. $actorId = 1009;
  146. $organizationId = 2;
  147.  
  148. $command = new \F6S\Crm\Command\DeleteOrganizationMember($actorId, $organizationId);
  149. $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteOrganizationMemberHandler::class);
  150. $handler->handle($command);
  151.  
  152.  
  153. //$this->orgMemberAppService->deleteMemberFromOrganization($actorId, $organizationId);
  154. }
  155.  
  156. public function removeAllAccess()
  157. {
  158. $actorId = 1009;
  159. $organizationId = 2;
  160.  
  161. $command = new \F6S\Crm\Command\RemoveAllAccess($actorId, $organizationId);
  162. $handler = $this->getService(\F6S\Crm\CommandHandler\RemoveAllAccessHandler::class);
  163. $handler->handle($command);
  164.  
  165. }
  166.  
  167. public function deleteMemberFromTeam()
  168. {
  169. $actorId = 1009;
  170. $teamId = 4;
  171.  
  172. $command = new \F6S\Crm\Command\DeleteTeamMember($actorId, $teamId);
  173. $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteTeamMemberHandler::class);
  174. $handler->handle($command);
  175. }
  176.  
  177. public function deleteTeam()
  178. {
  179. $teamId = 3;
  180.  
  181. $command = new \F6S\Crm\Command\DeleteTeam($teamId);
  182. $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteTeamHandler::class);
  183. $handler->handle($command);
  184. }
  185.  
  186. public function findActorOrganizations()
  187. {
  188. $actorId = $this->actorId;
  189. $organizations = $this->orgService->findActorOrganizations($actorId);
  190.  
  191. pr($organizations);
  192. exit;
  193. }
  194.  
  195. public function findTeamMemberData()
  196. {
  197. $actorId = 7776;
  198. $orgId = 1;
  199. $teamsMemberData = $this->teamMemberService->findTeamMemberData($actorId, $orgId);
  200.  
  201. pr($teamsMemberData);
  202. }
  203.  
  204. public function addPipeline()
  205. {
  206. $name = 'Pipeline 1';
  207. $this->pipelineService->add($name);
  208. }
  209.  
  210. public function findOrganizationPipelines()
  211. {
  212. $orgId = 1;
  213. $pipelines = $this->pipelineService->findOrganizationPipelines($orgId);
  214. pr($pipelines);
  215. }
  216.  
  217. public function prev()
  218. {
  219. /** @var \F6S\Crm\Service\OrganizationsService $orgService */
  220. $orgService = $this->getService(\F6S\Crm\Service\OrganizationsService::class);
  221.  
  222. /** @var \F6S\Crm\Service\TeamsService $teamService */
  223. $teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
  224.  
  225. /** @var \F6S\Crm\Service\OrganizationMemberAppService $orgMemberAppService */
  226. $orgMemberAppService = $this->getService(\F6S\Crm\Service\OrganizationMemberAppService::class);
  227.  
  228. $actorId = 7776;
  229. $name = 'Org2';
  230.  
  231. $orgId = 6;
  232. //$result = $orgService->findMembers($orgId);
  233.  
  234. $orgId = 7;
  235.  
  236. /** @var \F6S\Crm\Service\TeamsService $teamService */
  237. $teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
  238.  
  239. $teamName = 'team2';
  240. //$teamService->add($teamName, $orgId, $actorId);
  241.  
  242. $teamId = 5;
  243. $teamService->addMember($actorId, $teamId);
  244.  
  245. $position = 'cocalar1';
  246. $group = 'pizdulice2';
  247. //$orgService->updateMember($actorId, $orgId, $position, $group);
  248.  
  249. //$orgService->deleteMember($actorId,$orgId);
  250.  
  251. $teamService->deleteMember($actorId, $teamId);
  252. }
  253.  
  254. public function searchOrganizationMember()
  255. {
  256. $orgId = 1;
  257. $name = 'radi';
  258.  
  259. $members = $this->orgService->searchOrganizationMembers($orgId, $name);
  260. pr($members);
  261. }
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement