Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MainTestController extends Controller
- {
- /** @var \F6S\Crm\Service\OrganizationsService $orgService */
- private $orgService;
- /** @var \F6S\Crm\Service\TeamsService $teamService */
- private $teamService;
- /** @var \F6S\Crm\Service\OrganizationMemberAppService $orgMemberAppService */
- private $orgMemberAppService;
- /** @var \F6S\Crm\Service\PipelinesService $pipelineService */
- private $pipelineService;
- /** @var \F6S\Crm\Service\TeamMemberService $teamMemberService */
- private $teamMemberService;
- private $actorId;
- public function onDispatch()
- {
- $this->orgService = $this->getService(\F6S\Crm\Service\OrganizationsService::class);
- $this->teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
- $this->orgMemberAppService = $this->getService(\F6S\Crm\Service\OrganizationMemberAppService::class);
- $this->pipelineService = $this->getService(\F6S\Crm\Service\PipelinesService::class);
- $this->teamMemberService = $this->getService(\F6S\Crm\Service\TeamMemberService::class);
- $this->actorId = $this->top->collector->me->info['actor_id'];
- }
- public function truncateAll()
- {
- $tables = [
- 'acl_resources',
- 'acl_resource_permissions',
- 'acl_roles',
- 'acl_user_roles',
- 'crm_organizations',
- 'crm_people_to_organization',
- 'crm_teams',
- 'crm_people_to_team',
- 'crm_pipelines',
- 'crm_pipeline_owners',
- ];
- foreach ($tables as $table) {
- $query = "TRUNCATE TABLE `$table`";
- pr($query);
- $this->top->db->execute($query);
- }
- }
- public function addOrganization()
- {
- $name = 'Radu org ' . uniqid();
- $command = new \F6S\Crm\Command\AddOrganization($name, $this->actorId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\AddOrganizationHandler::class);
- $handler->handle($command);
- pr($command->getResult());
- }
- public function addMemberToOrganization()
- {
- $actorId = 666;
- $orgId = 5;
- $addOrganizationMemberHandler = $this->getService(\F6S\Crm\CommandHandler\AddOrganizationMemberHandler::class);
- $command = new \F6S\Crm\Command\AddOrganizationMember($actorId, $orgId);
- $addOrganizationMemberHandler->handle($command);
- pr($command->getResult());
- }
- public function updateMember()
- {
- $actorId = 7776;
- $orgId = 2;
- $position = null;
- $group = 'SW 20182';
- $command = new \F6S\Crm\Command\UpdateOrganizationMember($actorId, $orgId, $position, $group);
- $handler = $this->getService(\F6S\Crm\CommandHandler\UpdateOrganizationMemberHandler::class);
- $handler->handle($command);
- pr($command->getResult());
- }
- public function getOrganizationMembers()
- {
- $orgId = 2;
- $members = $this->orgService->findMembers($orgId);
- pr($members);
- }
- public function addTeam()
- {
- $name = 'Test Team 6';
- $organizationId = 2;
- $description = 'team description';
- $command = new \F6S\Crm\Command\AddTeam($name, $organizationId, $this->actorId, $description);
- $handler = $this->getService(\F6S\Crm\CommandHandler\AddTeamHandler::class);
- $handler->handle($command);
- pr($command->getResult());
- }
- public function findTeam()
- {
- $teamId = 9;
- $team = $this->teamService->findTeam($teamId);
- pr($team);
- }
- public function findMembers()
- {
- $teamId = 1;
- $members = $this->teamMemberService->findTeamMembers($teamId);
- pr($members);
- }
- public function findOrganizationTeams()
- {
- // FAILED
- $orgId = 2;
- $teams = $this->teamService->findOrganizationTeams($orgId);
- $results = [];
- foreach ($teams as $team) {
- $results[] = $team;
- }
- pr($results);
- }
- public function addMemberToTeam()
- {
- $actorId = 1009;
- $teamId = 4;
- $command = new \F6S\Crm\Command\AddMemberToTeam($actorId, $teamId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\AddMemberToTeamHandler::class);
- $handler->handle($command);
- }
- public function deleteMemberFromOrganization()
- {
- $actorId = 1009;
- $organizationId = 2;
- $command = new \F6S\Crm\Command\DeleteOrganizationMember($actorId, $organizationId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteOrganizationMemberHandler::class);
- $handler->handle($command);
- //$this->orgMemberAppService->deleteMemberFromOrganization($actorId, $organizationId);
- }
- public function removeAllAccess()
- {
- $actorId = 1009;
- $organizationId = 2;
- $command = new \F6S\Crm\Command\RemoveAllAccess($actorId, $organizationId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\RemoveAllAccessHandler::class);
- $handler->handle($command);
- }
- public function deleteMemberFromTeam()
- {
- $actorId = 1009;
- $teamId = 4;
- $command = new \F6S\Crm\Command\DeleteTeamMember($actorId, $teamId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteTeamMemberHandler::class);
- $handler->handle($command);
- }
- public function deleteTeam()
- {
- $teamId = 3;
- $command = new \F6S\Crm\Command\DeleteTeam($teamId);
- $handler = $this->getService(\F6S\Crm\CommandHandler\DeleteTeamHandler::class);
- $handler->handle($command);
- }
- public function findActorOrganizations()
- {
- $actorId = $this->actorId;
- $organizations = $this->orgService->findActorOrganizations($actorId);
- pr($organizations);
- exit;
- }
- public function findTeamMemberData()
- {
- $actorId = 7776;
- $orgId = 1;
- $teamsMemberData = $this->teamMemberService->findTeamMemberData($actorId, $orgId);
- pr($teamsMemberData);
- }
- public function addPipeline()
- {
- $name = 'Pipeline 1';
- $this->pipelineService->add($name);
- }
- public function findOrganizationPipelines()
- {
- $orgId = 1;
- $pipelines = $this->pipelineService->findOrganizationPipelines($orgId);
- pr($pipelines);
- }
- public function prev()
- {
- /** @var \F6S\Crm\Service\OrganizationsService $orgService */
- $orgService = $this->getService(\F6S\Crm\Service\OrganizationsService::class);
- /** @var \F6S\Crm\Service\TeamsService $teamService */
- $teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
- /** @var \F6S\Crm\Service\OrganizationMemberAppService $orgMemberAppService */
- $orgMemberAppService = $this->getService(\F6S\Crm\Service\OrganizationMemberAppService::class);
- $actorId = 7776;
- $name = 'Org2';
- $orgId = 6;
- //$result = $orgService->findMembers($orgId);
- $orgId = 7;
- /** @var \F6S\Crm\Service\TeamsService $teamService */
- $teamService = $this->getService(\F6S\Crm\Service\TeamsService::class);
- $teamName = 'team2';
- //$teamService->add($teamName, $orgId, $actorId);
- $teamId = 5;
- $teamService->addMember($actorId, $teamId);
- $position = 'cocalar1';
- $group = 'pizdulice2';
- //$orgService->updateMember($actorId, $orgId, $position, $group);
- //$orgService->deleteMember($actorId,$orgId);
- $teamService->deleteMember($actorId, $teamId);
- }
- public function searchOrganizationMember()
- {
- $orgId = 1;
- $name = 'radi';
- $members = $this->orgService->searchOrganizationMembers($orgId, $name);
- pr($members);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement