| Conditions | 46 |
| Total Lines | 770 |
| Code Lines | 429 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 653 | public function getPersonalDataToJson(int $userId, array $substitutionTerms) |
||
| 654 | { |
||
| 655 | $em = $this->getEntityManager(); |
||
| 656 | $dateFormat = Datetime::ATOM; |
||
| 657 | |||
| 658 | /** @var User $user */ |
||
| 659 | $user = $this->find($userId); |
||
| 660 | |||
| 661 | $user->setPassword($substitutionTerms['password']); |
||
| 662 | $user->setSalt($substitutionTerms['salt']); |
||
| 663 | $noDataLabel = $substitutionTerms['empty']; |
||
| 664 | |||
| 665 | // Dummy content |
||
| 666 | $user->setDateOfBirth(null); |
||
| 667 | //$user->setBiography($noDataLabel); |
||
| 668 | /*$user->setFacebookData($noDataLabel); |
||
| 669 | $user->setFacebookName($noDataLabel); |
||
| 670 | $user->setFacebookUid($noDataLabel);*/ |
||
| 671 | //$user->setImageName($noDataLabel); |
||
| 672 | //$user->setTwoStepVerificationCode($noDataLabel); |
||
| 673 | //$user->setGender($noDataLabel); |
||
| 674 | /*$user->setGplusData($noDataLabel); |
||
| 675 | $user->setGplusName($noDataLabel); |
||
| 676 | $user->setGplusUid($noDataLabel);*/ |
||
| 677 | $user->setLocale($noDataLabel); |
||
| 678 | $user->setTimezone($noDataLabel); |
||
| 679 | /*$user->setTwitterData($noDataLabel); |
||
| 680 | $user->setTwitterName($noDataLabel); |
||
| 681 | $user->setTwitterUid($noDataLabel);*/ |
||
| 682 | $user->setWebsite($noDataLabel); |
||
| 683 | //$user->setToken($noDataLabel); |
||
| 684 | |||
| 685 | $friends = SocialManager::get_friends($userId); |
||
| 686 | $friendList = []; |
||
| 687 | if (!empty($friends)) { |
||
| 688 | foreach ($friends as $friend) { |
||
| 689 | $friendList[] = $friend['user_info']['complete_name']; |
||
| 690 | } |
||
| 691 | } |
||
| 692 | |||
| 693 | $agenda = new Agenda('personal'); |
||
| 694 | $events = $agenda->getEvents(0, 0, 0, 0, $userId, 'array'); |
||
| 695 | $eventList = []; |
||
| 696 | if (!empty($events)) { |
||
| 697 | foreach ($events as $event) { |
||
| 698 | $eventList[] = $event['title'].' '.$event['start_date_localtime'].' / '.$event['end_date_localtime']; |
||
| 699 | } |
||
| 700 | } |
||
| 701 | |||
| 702 | // GradebookCertificate |
||
| 703 | $criteria = [ |
||
| 704 | 'userId' => $userId, |
||
| 705 | ]; |
||
| 706 | $result = $em->getRepository(GradebookCertificate::class)->findBy($criteria); |
||
| 707 | $gradebookCertificate = []; |
||
| 708 | /** @var GradebookCertificate $item */ |
||
| 709 | foreach ($result as $item) { |
||
| 710 | $createdAt = $item->getCreatedAt()->format($dateFormat); |
||
| 711 | $list = [ |
||
| 712 | 'Score: '.$item->getScoreCertificate(), |
||
| 713 | 'Path: '.$item->getPathCertificate(), |
||
| 714 | 'Created at: '.$createdAt, |
||
| 715 | ]; |
||
| 716 | $gradebookCertificate[] = implode(', ', $list); |
||
| 717 | } |
||
| 718 | |||
| 719 | // TrackEExercises |
||
| 720 | $criteria = [ |
||
| 721 | 'exeUserId' => $userId, |
||
| 722 | ]; |
||
| 723 | $result = $em->getRepository(TrackEExercises::class)->findBy($criteria); |
||
| 724 | $trackEExercises = []; |
||
| 725 | /** @var TrackEExercises $item */ |
||
| 726 | foreach ($result as $item) { |
||
| 727 | $date = $item->getExeDate()->format($dateFormat); |
||
| 728 | $list = [ |
||
| 729 | 'IP: '.$item->getUserIp(), |
||
| 730 | 'Start: '.$date, |
||
| 731 | 'Status: '.$item->getStatus(), |
||
| 732 | // 'Result: '.$item->getExeResult(), |
||
| 733 | // 'Weighting: '.$item->getExeWeighting(), |
||
| 734 | ]; |
||
| 735 | $trackEExercises[] = implode(', ', $list); |
||
| 736 | } |
||
| 737 | |||
| 738 | // TrackEAttempt |
||
| 739 | $criteria = [ |
||
| 740 | 'userId' => $userId, |
||
| 741 | ]; |
||
| 742 | $result = $em->getRepository(TrackEAttempt::class)->findBy($criteria); |
||
| 743 | $trackEAttempt = []; |
||
| 744 | /** @var TrackEAttempt $item */ |
||
| 745 | foreach ($result as $item) { |
||
| 746 | $date = $item->getTms()->format($dateFormat); |
||
| 747 | $list = [ |
||
| 748 | 'Attempt #'.$item->getExeId(), |
||
| 749 | 'Course # '.$item->getCourse()->getCode(), |
||
| 750 | //'Answer: '.$item->getAnswer(), |
||
| 751 | 'Session #'.$item->getSessionId(), |
||
| 752 | //'Marks: '.$item->getMarks(), |
||
| 753 | 'Position: '.$item->getPosition(), |
||
| 754 | 'Date: '.$date, |
||
| 755 | ]; |
||
| 756 | $trackEAttempt[] = implode(', ', $list); |
||
| 757 | } |
||
| 758 | |||
| 759 | // TrackECourseAccess |
||
| 760 | $criteria = [ |
||
| 761 | 'userId' => $userId, |
||
| 762 | ]; |
||
| 763 | $result = $em->getRepository(TrackECourseAccess::class)->findBy($criteria); |
||
| 764 | $trackECourseAccessList = []; |
||
| 765 | /** @var TrackECourseAccess $item */ |
||
| 766 | foreach ($result as $item) { |
||
| 767 | $startDate = $item->getLoginCourseDate()->format($dateFormat); |
||
| 768 | $endDate = null !== $item->getLogoutCourseDate() ? $item->getLogoutCourseDate()->format($dateFormat) : ''; |
||
| 769 | $list = [ |
||
| 770 | 'IP: '.$item->getUserIp(), |
||
| 771 | 'Start: '.$startDate, |
||
| 772 | 'End: '.$endDate, |
||
| 773 | ]; |
||
| 774 | $trackECourseAccessList[] = implode(', ', $list); |
||
| 775 | } |
||
| 776 | |||
| 777 | $checkEntities = [ |
||
| 778 | TrackELogin::class => 'loginUserId', |
||
| 779 | TrackEAccess::class => 'accessUserId', |
||
| 780 | TrackEOnline::class => 'loginUserId', |
||
| 781 | TrackEDefault::class => 'defaultUserId', |
||
| 782 | TrackELastaccess::class => 'accessUserId', |
||
| 783 | TrackEUploads::class => 'uploadUserId', |
||
| 784 | GradebookResult::class => 'userId', |
||
| 785 | TrackEDownloads::class => 'downUserId', |
||
| 786 | ]; |
||
| 787 | |||
| 788 | $maxResults = 1000; |
||
| 789 | $trackResults = []; |
||
| 790 | foreach ($checkEntities as $entity => $field) { |
||
| 791 | $qb = $em->createQueryBuilder(); |
||
| 792 | $qb->select($qb->expr()->count('l')) |
||
| 793 | ->from($entity, 'l') |
||
| 794 | ->where("l.{$field} = :login") |
||
| 795 | ->setParameter('login', $userId) |
||
| 796 | ; |
||
| 797 | $query = $qb->getQuery(); |
||
| 798 | $count = $query->getSingleScalarResult(); |
||
| 799 | |||
| 800 | if ($count > $maxResults) { |
||
| 801 | $qb = $em->getRepository($entity)->createQueryBuilder('l'); |
||
| 802 | $qb |
||
| 803 | ->select('l') |
||
| 804 | ->where("l.{$field} = :login") |
||
| 805 | ->setParameter('login', $userId) |
||
| 806 | ; |
||
| 807 | $qb |
||
| 808 | ->setFirstResult(0) |
||
| 809 | ->setMaxResults($maxResults) |
||
| 810 | ; |
||
| 811 | $result = $qb->getQuery()->getResult(); |
||
| 812 | } else { |
||
| 813 | $criteria = [ |
||
| 814 | $field => $userId, |
||
| 815 | ]; |
||
| 816 | $result = $em->getRepository($entity)->findBy($criteria); |
||
| 817 | } |
||
| 818 | $trackResults[$entity] = $result; |
||
| 819 | } |
||
| 820 | |||
| 821 | $trackELoginList = []; |
||
| 822 | /** @var TrackELogin $item */ |
||
| 823 | foreach ($trackResults['ChamiloCoreBundle:TrackELogin'] as $item) { |
||
| 824 | $startDate = $item->getLoginDate()->format($dateFormat); |
||
| 825 | $endDate = null !== $item->getLogoutDate() ? $item->getLogoutDate()->format($dateFormat) : ''; |
||
| 826 | $list = [ |
||
| 827 | 'IP: '.$item->getUserIp(), |
||
| 828 | 'Start: '.$startDate, |
||
| 829 | 'End: '.$endDate, |
||
| 830 | ]; |
||
| 831 | $trackELoginList[] = implode(', ', $list); |
||
| 832 | } |
||
| 833 | |||
| 834 | // TrackEAccess |
||
| 835 | $trackEAccessList = []; |
||
| 836 | /** @var TrackEAccess $item */ |
||
| 837 | foreach ($trackResults['ChamiloCoreBundle:TrackEAccess'] as $item) { |
||
| 838 | $date = $item->getAccessDate()->format($dateFormat); |
||
| 839 | $list = [ |
||
| 840 | 'IP: '.$item->getUserIp(), |
||
| 841 | 'Tool: '.$item->getAccessTool(), |
||
| 842 | 'End: '.$date, |
||
| 843 | ]; |
||
| 844 | $trackEAccessList[] = implode(', ', $list); |
||
| 845 | } |
||
| 846 | |||
| 847 | // TrackEOnline |
||
| 848 | $trackEOnlineList = []; |
||
| 849 | /** @var TrackEOnline $item */ |
||
| 850 | foreach ($trackResults['ChamiloCoreBundle:TrackEOnline'] as $item) { |
||
| 851 | $date = $item->getLoginDate()->format($dateFormat); |
||
| 852 | $list = [ |
||
| 853 | 'IP: '.$item->getUserIp(), |
||
| 854 | 'Login date: '.$date, |
||
| 855 | 'Course # '.$item->getCId(), |
||
| 856 | 'Session # '.$item->getSessionId(), |
||
| 857 | ]; |
||
| 858 | $trackEOnlineList[] = implode(', ', $list); |
||
| 859 | } |
||
| 860 | |||
| 861 | // TrackEDefault |
||
| 862 | $trackEDefault = []; |
||
| 863 | /** @var TrackEDefault $item */ |
||
| 864 | foreach ($trackResults['ChamiloCoreBundle:TrackEDefault'] as $item) { |
||
| 865 | $date = $item->getDefaultDate()->format($dateFormat); |
||
| 866 | $list = [ |
||
| 867 | 'Type: '.$item->getDefaultEventType(), |
||
| 868 | 'Value: '.$item->getDefaultValue(), |
||
| 869 | 'Value type: '.$item->getDefaultValueType(), |
||
| 870 | 'Date: '.$date, |
||
| 871 | 'Course #'.$item->getCId(), |
||
| 872 | 'Session # '.$item->getSessionId(), |
||
| 873 | ]; |
||
| 874 | $trackEDefault[] = implode(', ', $list); |
||
| 875 | } |
||
| 876 | |||
| 877 | // TrackELastaccess |
||
| 878 | $trackELastaccess = []; |
||
| 879 | /** @var TrackELastaccess $item */ |
||
| 880 | foreach ($trackResults['ChamiloCoreBundle:TrackELastaccess'] as $item) { |
||
| 881 | $date = $item->getAccessDate()->format($dateFormat); |
||
| 882 | $list = [ |
||
| 883 | 'Course #'.$item->getCId(), |
||
| 884 | 'Session # '.$item->getAccessSessionId(), |
||
| 885 | 'Tool: '.$item->getAccessTool(), |
||
| 886 | 'Access date: '.$date, |
||
| 887 | ]; |
||
| 888 | $trackELastaccess[] = implode(', ', $list); |
||
| 889 | } |
||
| 890 | |||
| 891 | // TrackEUploads |
||
| 892 | $trackEUploads = []; |
||
| 893 | /** @var TrackEUploads $item */ |
||
| 894 | foreach ($trackResults['ChamiloCoreBundle:TrackEUploads'] as $item) { |
||
| 895 | $date = $item->getUploadDate()->format($dateFormat); |
||
| 896 | $list = [ |
||
| 897 | 'Course #'.$item->getCId(), |
||
| 898 | 'Uploaded at: '.$date, |
||
| 899 | 'Upload id # '.$item->getUploadId(), |
||
| 900 | ]; |
||
| 901 | $trackEUploads[] = implode(', ', $list); |
||
| 902 | } |
||
| 903 | |||
| 904 | $gradebookResult = []; |
||
| 905 | /** @var GradebookResult $item */ |
||
| 906 | foreach ($trackResults['ChamiloCoreBundle:GradebookResult'] as $item) { |
||
| 907 | $date = $item->getCreatedAt()->format($dateFormat); |
||
| 908 | $list = [ |
||
| 909 | 'Evaluation id# '.$item->getEvaluation()->getId(), |
||
| 910 | //'Score: '.$item->getScore(), |
||
| 911 | 'Creation date: '.$date, |
||
| 912 | ]; |
||
| 913 | $gradebookResult[] = implode(', ', $list); |
||
| 914 | } |
||
| 915 | |||
| 916 | $trackEDownloads = []; |
||
| 917 | /** @var TrackEDownloads $item */ |
||
| 918 | foreach ($trackResults['ChamiloCoreBundle:TrackEDownloads'] as $item) { |
||
| 919 | $date = $item->getDownDate()->format($dateFormat); |
||
| 920 | $list = [ |
||
| 921 | 'File: '.$item->getDownDocPath(), |
||
| 922 | 'Download at: '.$date, |
||
| 923 | ]; |
||
| 924 | $trackEDownloads[] = implode(', ', $list); |
||
| 925 | } |
||
| 926 | |||
| 927 | // UserCourseCategory |
||
| 928 | $criteria = [ |
||
| 929 | 'userId' => $userId, |
||
| 930 | ]; |
||
| 931 | $result = $em->getRepository(UserCourseCategory::class)->findBy($criteria); |
||
| 932 | $userCourseCategory = []; |
||
| 933 | /** @var UserCourseCategory $item */ |
||
| 934 | foreach ($result as $item) { |
||
| 935 | $list = [ |
||
| 936 | 'Title: '.$item->getTitle(), |
||
| 937 | ]; |
||
| 938 | $userCourseCategory[] = implode(', ', $list); |
||
| 939 | } |
||
| 940 | |||
| 941 | // Forum |
||
| 942 | $criteria = [ |
||
| 943 | 'posterId' => $userId, |
||
| 944 | ]; |
||
| 945 | $result = $em->getRepository(CForumPost::class)->findBy($criteria); |
||
| 946 | $cForumPostList = []; |
||
| 947 | /** @var CForumPost $item */ |
||
| 948 | foreach ($result as $item) { |
||
| 949 | $date = $item->getPostDate()->format($dateFormat); |
||
| 950 | $list = [ |
||
| 951 | 'Title: '.$item->getPostTitle(), |
||
| 952 | 'Creation date: '.$date, |
||
| 953 | ]; |
||
| 954 | $cForumPostList[] = implode(', ', $list); |
||
| 955 | } |
||
| 956 | |||
| 957 | // CForumThread |
||
| 958 | $criteria = [ |
||
| 959 | 'threadPosterId' => $userId, |
||
| 960 | ]; |
||
| 961 | $result = $em->getRepository(CForumThread::class)->findBy($criteria); |
||
| 962 | $cForumThreadList = []; |
||
| 963 | /** @var CForumThread $item */ |
||
| 964 | foreach ($result as $item) { |
||
| 965 | $date = $item->getThreadDate()->format($dateFormat); |
||
| 966 | $list = [ |
||
| 967 | 'Title: '.$item->getThreadTitle(), |
||
| 968 | 'Creation date: '.$date, |
||
| 969 | ]; |
||
| 970 | $cForumThreadList[] = implode(', ', $list); |
||
| 971 | } |
||
| 972 | |||
| 973 | // CForumAttachment |
||
| 974 | /*$criteria = [ |
||
| 975 | 'threadPosterId' => $userId, |
||
| 976 | ]; |
||
| 977 | $result = $em->getRepository('ChamiloCourseBundle:CForumAttachment')->findBy($criteria); |
||
| 978 | $cForumThreadList = []; |
||
| 979 | * @var CForumThread $item |
||
| 980 | foreach ($result as $item) { |
||
| 981 | $list = [ |
||
| 982 | 'Title: '.$item->getThreadTitle(), |
||
| 983 | 'Creation date: '.$item->getThreadDate()->format($dateFormat), |
||
| 984 | ]; |
||
| 985 | $cForumThreadList[] = implode(', ', $list); |
||
| 986 | }*/ |
||
| 987 | |||
| 988 | // cGroupRelUser |
||
| 989 | $criteria = [ |
||
| 990 | 'user' => $userId, |
||
| 991 | ]; |
||
| 992 | $result = $em->getRepository(CGroupRelUser::class)->findBy($criteria); |
||
| 993 | $cGroupRelUser = []; |
||
| 994 | /** @var CGroupRelUser $item */ |
||
| 995 | foreach ($result as $item) { |
||
| 996 | $list = [ |
||
| 997 | 'Course # '.$item->getCId(), |
||
| 998 | 'Group #'.$item->getGroup()->getIid(), |
||
| 999 | 'Role: '.$item->getStatus(), |
||
| 1000 | ]; |
||
| 1001 | $cGroupRelUser[] = implode(', ', $list); |
||
| 1002 | } |
||
| 1003 | |||
| 1004 | // CAttendanceSheet |
||
| 1005 | $criteria = [ |
||
| 1006 | 'userId' => $userId, |
||
| 1007 | ]; |
||
| 1008 | $result = $em->getRepository(CAttendanceSheet::class)->findBy($criteria); |
||
| 1009 | $cAttendanceSheetList = []; |
||
| 1010 | /** @var CAttendanceSheet $item */ |
||
| 1011 | foreach ($result as $item) { |
||
| 1012 | $list = [ |
||
| 1013 | 'Presence: '.$item->getPresence(), |
||
| 1014 | 'Calendar id: '.$item->getAttendanceCalendar()->getIid(), |
||
| 1015 | ]; |
||
| 1016 | $cAttendanceSheetList[] = implode(', ', $list); |
||
| 1017 | } |
||
| 1018 | |||
| 1019 | // CBlogPost |
||
| 1020 | $criteria = [ |
||
| 1021 | 'authorId' => $userId, |
||
| 1022 | ]; |
||
| 1023 | $result = $em->getRepository(CBlogPost::class)->findBy($criteria); |
||
| 1024 | $cBlog = []; |
||
| 1025 | /** @var CBlogPost $item */ |
||
| 1026 | foreach ($result as $item) { |
||
| 1027 | $date = $item->getDateCreation()->format($dateFormat); |
||
| 1028 | $list = [ |
||
| 1029 | 'Title: '.$item->getTitle(), |
||
| 1030 | 'Date: '.$date, |
||
| 1031 | ]; |
||
| 1032 | $cBlog[] = implode(', ', $list); |
||
| 1033 | } |
||
| 1034 | |||
| 1035 | // CAttendanceResult |
||
| 1036 | $criteria = [ |
||
| 1037 | 'userId' => $userId, |
||
| 1038 | ]; |
||
| 1039 | $result = $em->getRepository(CAttendanceResult::class)->findBy($criteria); |
||
| 1040 | $cAttendanceResult = []; |
||
| 1041 | /** @var CAttendanceResult $item */ |
||
| 1042 | foreach ($result as $item) { |
||
| 1043 | $list = [ |
||
| 1044 | 'Score : '.$item->getScore(), |
||
| 1045 | 'Calendar id: '.$item->getAttendance()->getIid(), |
||
| 1046 | ]; |
||
| 1047 | $cAttendanceResult[] = implode(', ', $list); |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | // Message |
||
| 1051 | $criteria = [ |
||
| 1052 | 'userSender' => $userId, |
||
| 1053 | ]; |
||
| 1054 | $result = $em->getRepository(Message::class)->findBy($criteria); |
||
| 1055 | $messageList = []; |
||
| 1056 | /** @var Message $item */ |
||
| 1057 | foreach ($result as $item) { |
||
| 1058 | $date = $item->getSendDate()->format($dateFormat); |
||
| 1059 | $userName = ''; |
||
| 1060 | if ($item->getUserReceiver()) { |
||
| 1061 | $userName = $item->getUserReceiver()->getUsername(); |
||
| 1062 | } |
||
| 1063 | $list = [ |
||
| 1064 | 'Title: '.$item->getTitle(), |
||
| 1065 | 'Sent date: '.$date, |
||
| 1066 | 'To user: '.$userName, |
||
| 1067 | 'Status'.$item->getMsgStatus(), |
||
| 1068 | ]; |
||
| 1069 | $messageList[] = implode(', ', $list); |
||
| 1070 | } |
||
| 1071 | |||
| 1072 | // CSurveyAnswer |
||
| 1073 | $criteria = [ |
||
| 1074 | 'user' => $userId, |
||
| 1075 | ]; |
||
| 1076 | $result = $em->getRepository(CSurveyAnswer::class)->findBy($criteria); |
||
| 1077 | $cSurveyAnswer = []; |
||
| 1078 | /** @var CSurveyAnswer $item */ |
||
| 1079 | foreach ($result as $item) { |
||
| 1080 | $list = [ |
||
| 1081 | 'Answer # '.$item->getIid(), |
||
| 1082 | 'Value: '.$item->getValue(), |
||
| 1083 | ]; |
||
| 1084 | $cSurveyAnswer[] = implode(', ', $list); |
||
| 1085 | } |
||
| 1086 | |||
| 1087 | // CDropboxFile |
||
| 1088 | $criteria = [ |
||
| 1089 | 'uploaderId' => $userId, |
||
| 1090 | ]; |
||
| 1091 | $result = $em->getRepository(CDropboxFile::class)->findBy($criteria); |
||
| 1092 | $cDropboxFile = []; |
||
| 1093 | /** @var CDropboxFile $item */ |
||
| 1094 | foreach ($result as $item) { |
||
| 1095 | $date = $item->getUploadDate()->format($dateFormat); |
||
| 1096 | $list = [ |
||
| 1097 | 'Title: '.$item->getTitle(), |
||
| 1098 | 'Uploaded date: '.$date, |
||
| 1099 | 'File: '.$item->getFilename(), |
||
| 1100 | ]; |
||
| 1101 | $cDropboxFile[] = implode(', ', $list); |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | // CDropboxPerson |
||
| 1105 | $criteria = [ |
||
| 1106 | 'userId' => $userId, |
||
| 1107 | ]; |
||
| 1108 | $result = $em->getRepository(CDropboxPerson::class)->findBy($criteria); |
||
| 1109 | $cDropboxPerson = []; |
||
| 1110 | /** @var CDropboxPerson $item */ |
||
| 1111 | foreach ($result as $item) { |
||
| 1112 | $list = [ |
||
| 1113 | 'File #'.$item->getFileId(), |
||
| 1114 | 'Course #'.$item->getCId(), |
||
| 1115 | ]; |
||
| 1116 | $cDropboxPerson[] = implode(', ', $list); |
||
| 1117 | } |
||
| 1118 | |||
| 1119 | // CDropboxPerson |
||
| 1120 | $criteria = [ |
||
| 1121 | 'authorUserId' => $userId, |
||
| 1122 | ]; |
||
| 1123 | $result = $em->getRepository(CDropboxFeedback::class)->findBy($criteria); |
||
| 1124 | $cDropboxFeedback = []; |
||
| 1125 | /** @var CDropboxFeedback $item */ |
||
| 1126 | foreach ($result as $item) { |
||
| 1127 | $date = $item->getFeedbackDate()->format($dateFormat); |
||
| 1128 | $list = [ |
||
| 1129 | 'File #'.$item->getFileId(), |
||
| 1130 | 'Feedback: '.$item->getFeedback(), |
||
| 1131 | 'Date: '.$date, |
||
| 1132 | ]; |
||
| 1133 | $cDropboxFeedback[] = implode(', ', $list); |
||
| 1134 | } |
||
| 1135 | |||
| 1136 | // CNotebook |
||
| 1137 | $criteria = [ |
||
| 1138 | 'userId' => $userId, |
||
| 1139 | ]; |
||
| 1140 | $result = $em->getRepository(CNotebook::class)->findBy($criteria); |
||
| 1141 | $cNotebook = []; |
||
| 1142 | /** @var CNotebook $item */ |
||
| 1143 | foreach ($result as $item) { |
||
| 1144 | $date = $item->getUpdateDate()->format($dateFormat); |
||
| 1145 | $list = [ |
||
| 1146 | 'Title: '.$item->getTitle(), |
||
| 1147 | 'Date: '.$date, |
||
| 1148 | ]; |
||
| 1149 | $cNotebook[] = implode(', ', $list); |
||
| 1150 | } |
||
| 1151 | |||
| 1152 | // CLpView |
||
| 1153 | $criteria = [ |
||
| 1154 | 'userId' => $userId, |
||
| 1155 | ]; |
||
| 1156 | $result = $em->getRepository(CLpView::class)->findBy($criteria); |
||
| 1157 | $cLpView = []; |
||
| 1158 | /** @var CLpView $item */ |
||
| 1159 | foreach ($result as $item) { |
||
| 1160 | $list = [ |
||
| 1161 | //'Id #'.$item->getId(), |
||
| 1162 | 'LP #'.$item->getLpId(), |
||
| 1163 | 'Progress: '.$item->getProgress(), |
||
| 1164 | 'Course #'.$item->getCId(), |
||
| 1165 | 'Session #'.$item->getSessionId(), |
||
| 1166 | ]; |
||
| 1167 | $cLpView[] = implode(', ', $list); |
||
| 1168 | } |
||
| 1169 | |||
| 1170 | // CStudentPublication |
||
| 1171 | $criteria = [ |
||
| 1172 | 'userId' => $userId, |
||
| 1173 | ]; |
||
| 1174 | $result = $em->getRepository(CStudentPublication::class)->findBy($criteria); |
||
| 1175 | $cStudentPublication = []; |
||
| 1176 | /** @var CStudentPublication $item */ |
||
| 1177 | foreach ($result as $item) { |
||
| 1178 | $list = [ |
||
| 1179 | 'Title: '.$item->getTitle(), |
||
| 1180 | //'URL: '.$item->getTitle(), |
||
| 1181 | ]; |
||
| 1182 | $cStudentPublication[] = implode(', ', $list); |
||
| 1183 | } |
||
| 1184 | |||
| 1185 | // CStudentPublicationComment |
||
| 1186 | $criteria = [ |
||
| 1187 | 'userId' => $userId, |
||
| 1188 | ]; |
||
| 1189 | $result = $em->getRepository(CStudentPublicationComment::class)->findBy($criteria); |
||
| 1190 | $cStudentPublicationComment = []; |
||
| 1191 | /** @var CStudentPublicationComment $item */ |
||
| 1192 | foreach ($result as $item) { |
||
| 1193 | $date = $item->getSentAt()->format($dateFormat); |
||
| 1194 | $list = [ |
||
| 1195 | 'Commment: '.$item->getComment(), |
||
| 1196 | 'File '.$item->getFile(), |
||
| 1197 | //'Course # '.$item->getCId(), |
||
| 1198 | 'Date: '.$date, |
||
| 1199 | ]; |
||
| 1200 | $cStudentPublicationComment[] = implode(', ', $list); |
||
| 1201 | } |
||
| 1202 | |||
| 1203 | // CWiki |
||
| 1204 | $criteria = [ |
||
| 1205 | 'userId' => $userId, |
||
| 1206 | ]; |
||
| 1207 | $result = $em->getRepository(CWiki::class)->findBy($criteria); |
||
| 1208 | $cWiki = []; |
||
| 1209 | /** @var CWiki $item */ |
||
| 1210 | foreach ($result as $item) { |
||
| 1211 | $list = [ |
||
| 1212 | 'Title: '.$item->getTitle(), |
||
| 1213 | 'Progress: '.$item->getProgress(), |
||
| 1214 | 'IP: '.$item->getUserIp(), |
||
| 1215 | ]; |
||
| 1216 | $cWiki[] = implode(', ', $list); |
||
| 1217 | } |
||
| 1218 | |||
| 1219 | // Ticket |
||
| 1220 | $criteria = [ |
||
| 1221 | 'insertUserId' => $userId, |
||
| 1222 | ]; |
||
| 1223 | $result = $em->getRepository(Ticket::class)->findBy($criteria); |
||
| 1224 | $ticket = []; |
||
| 1225 | /** @var Ticket $item */ |
||
| 1226 | foreach ($result as $item) { |
||
| 1227 | $list = [ |
||
| 1228 | 'Code: '.$item->getCode(), |
||
| 1229 | 'Subject: '.$item->getSubject(), |
||
| 1230 | ]; |
||
| 1231 | $ticket[] = implode(', ', $list); |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | // Message |
||
| 1235 | $criteria = [ |
||
| 1236 | 'insertUserId' => $userId, |
||
| 1237 | ]; |
||
| 1238 | $result = $em->getRepository(TicketMessage::class)->findBy($criteria); |
||
| 1239 | $ticketMessage = []; |
||
| 1240 | /** @var TicketMessage $item */ |
||
| 1241 | foreach ($result as $item) { |
||
| 1242 | $date = $item->getInsertDateTime()->format($dateFormat); |
||
| 1243 | $list = [ |
||
| 1244 | 'Subject: '.$item->getSubject(), |
||
| 1245 | 'IP: '.$item->getIpAddress(), |
||
| 1246 | 'Status: '.$item->getStatus(), |
||
| 1247 | 'Creation date: '.$date, |
||
| 1248 | ]; |
||
| 1249 | $ticketMessage[] = implode(', ', $list); |
||
| 1250 | } |
||
| 1251 | |||
| 1252 | // SkillRelUserComment |
||
| 1253 | $criteria = [ |
||
| 1254 | 'feedbackGiver' => $userId, |
||
| 1255 | ]; |
||
| 1256 | $result = $em->getRepository(SkillRelUserComment::class)->findBy($criteria); |
||
| 1257 | $skillRelUserComment = []; |
||
| 1258 | /** @var SkillRelUserComment $item */ |
||
| 1259 | foreach ($result as $item) { |
||
| 1260 | $date = $item->getFeedbackDateTime()->format($dateFormat); |
||
| 1261 | $list = [ |
||
| 1262 | 'Feedback: '.$item->getFeedbackText(), |
||
| 1263 | 'Value: '.$item->getFeedbackValue(), |
||
| 1264 | 'Created at: '.$date, |
||
| 1265 | ]; |
||
| 1266 | $skillRelUserComment[] = implode(', ', $list); |
||
| 1267 | } |
||
| 1268 | |||
| 1269 | // UserRelCourseVote |
||
| 1270 | $criteria = [ |
||
| 1271 | 'userId' => $userId, |
||
| 1272 | ]; |
||
| 1273 | $result = $em->getRepository(UserRelCourseVote::class)->findBy($criteria); |
||
| 1274 | $userRelCourseVote = []; |
||
| 1275 | /** @var UserRelCourseVote $item */ |
||
| 1276 | foreach ($result as $item) { |
||
| 1277 | $list = [ |
||
| 1278 | 'Course #'.$item->getCId(), |
||
| 1279 | 'Session #'.$item->getSessionId(), |
||
| 1280 | 'Vote: '.$item->getVote(), |
||
| 1281 | ]; |
||
| 1282 | $userRelCourseVote[] = implode(', ', $list); |
||
| 1283 | } |
||
| 1284 | |||
| 1285 | /*$user->setDropBoxSentFiles( |
||
| 1286 | [ |
||
| 1287 | 'Friends' => $friendList, |
||
| 1288 | 'Events' => $eventList, |
||
| 1289 | 'GradebookCertificate' => $gradebookCertificate, |
||
| 1290 | |||
| 1291 | 'TrackECourseAccess' => $trackECourseAccessList, |
||
| 1292 | 'TrackELogin' => $trackELoginList, |
||
| 1293 | 'TrackEAccess' => $trackEAccessList, |
||
| 1294 | 'TrackEDefault' => $trackEDefault, |
||
| 1295 | 'TrackEOnline' => $trackEOnlineList, |
||
| 1296 | 'TrackEUploads' => $trackEUploads, |
||
| 1297 | 'TrackELastaccess' => $trackELastaccess, |
||
| 1298 | 'GradebookResult' => $gradebookResult, |
||
| 1299 | 'Downloads' => $trackEDownloads, |
||
| 1300 | 'UserCourseCategory' => $userCourseCategory, |
||
| 1301 | 'SkillRelUserComment' => $skillRelUserComment, |
||
| 1302 | 'UserRelCourseVote' => $userRelCourseVote, |
||
| 1303 | |||
| 1304 | // courses |
||
| 1305 | 'AttendanceResult' => $cAttendanceResult, |
||
| 1306 | 'Blog' => $cBlog, |
||
| 1307 | 'DocumentsAdded' => $documents, |
||
| 1308 | 'Chat' => $chatFiles, |
||
| 1309 | 'ForumPost' => $cForumPostList, |
||
| 1310 | 'ForumThread' => $cForumThreadList, |
||
| 1311 | 'TrackEExercises' => $trackEExercises, |
||
| 1312 | 'TrackEAttempt' => $trackEAttempt, |
||
| 1313 | |||
| 1314 | 'GroupRelUser' => $cGroupRelUser, |
||
| 1315 | 'Message' => $messageList, |
||
| 1316 | 'Survey' => $cSurveyAnswer, |
||
| 1317 | 'StudentPublication' => $cStudentPublication, |
||
| 1318 | 'StudentPublicationComment' => $cStudentPublicationComment, |
||
| 1319 | 'DropboxFile' => $cDropboxFile, |
||
| 1320 | 'DropboxPerson' => $cDropboxPerson, |
||
| 1321 | 'DropboxFeedback' => $cDropboxFeedback, |
||
| 1322 | |||
| 1323 | 'LpView' => $cLpView, |
||
| 1324 | 'Notebook' => $cNotebook, |
||
| 1325 | |||
| 1326 | 'Wiki' => $cWiki, |
||
| 1327 | // Tickets |
||
| 1328 | |||
| 1329 | 'Ticket' => $ticket, |
||
| 1330 | 'TicketMessage' => $ticketMessage, |
||
| 1331 | ] |
||
| 1332 | );*/ |
||
| 1333 | |||
| 1334 | //$user->setDropBoxReceivedFiles([]); |
||
| 1335 | //$user->setGroups([]); |
||
| 1336 | //$user->setCurriculumItems([]); |
||
| 1337 | |||
| 1338 | /*$portals = $user->getPortals(); |
||
| 1339 | if (!empty($portals)) { |
||
| 1340 | $list = []; |
||
| 1341 | /** @var AccessUrlRelUser $portal */ |
||
| 1342 | /*foreach ($portals as $portal) { |
||
| 1343 | $portalInfo = UrlManager::get_url_data_from_id($portal->getUrl()->getId()); |
||
| 1344 | $list[] = $portalInfo['url']; |
||
| 1345 | } |
||
| 1346 | } |
||
| 1347 | $user->setPortals($list);*/ |
||
| 1348 | |||
| 1349 | /*$skillRelUserList = $user->getAchievedSkills(); |
||
| 1350 | $list = []; |
||
| 1351 | foreach ($skillRelUserList as $skillRelUser) { |
||
| 1352 | $list[] = $skillRelUser->getSkill()->getName(); |
||
| 1353 | } |
||
| 1354 | $user->setAchievedSkills($list); |
||
| 1355 | $user->setCommentedUserSkills([]);*/ |
||
| 1356 | |||
| 1357 | //$extraFieldValues = new \ExtraFieldValue('user'); |
||
| 1358 | |||
| 1359 | $lastLogin = $user->getLastLogin(); |
||
| 1360 | if (empty($lastLogin)) { |
||
| 1361 | $login = $this->getLastLogin($user); |
||
| 1362 | if (null !== $login) { |
||
| 1363 | $lastLogin = $login->getLoginDate(); |
||
| 1364 | } |
||
| 1365 | } |
||
| 1366 | $user->setLastLogin($lastLogin); |
||
| 1367 | |||
| 1368 | /*$dateNormalizer = new GetSetMethodNormalizer(); |
||
| 1369 | $dateNormalizer->setCircularReferenceHandler(function ($object) { |
||
| 1370 | return get_class($object); |
||
| 1371 | });*/ |
||
| 1372 | |||
| 1373 | $ignore = [ |
||
| 1374 | 'twoStepVerificationCode', |
||
| 1375 | 'biography', |
||
| 1376 | 'dateOfBirth', |
||
| 1377 | 'gender', |
||
| 1378 | 'facebookData', |
||
| 1379 | 'facebookName', |
||
| 1380 | 'facebookUid', |
||
| 1381 | 'gplusData', |
||
| 1382 | 'gplusName', |
||
| 1383 | 'gplusUid', |
||
| 1384 | 'locale', |
||
| 1385 | 'timezone', |
||
| 1386 | 'twitterData', |
||
| 1387 | 'twitterName', |
||
| 1388 | 'twitterUid', |
||
| 1389 | 'gplusUid', |
||
| 1390 | 'token', |
||
| 1391 | 'website', |
||
| 1392 | 'plainPassword', |
||
| 1393 | 'completeNameWithUsername', |
||
| 1394 | 'completeName', |
||
| 1395 | 'completeNameWithClasses', |
||
| 1396 | 'salt', |
||
| 1397 | ]; |
||
| 1398 | |||
| 1399 | $callback = function ($dateTime) { |
||
| 1400 | return $dateTime instanceof DateTime ? $dateTime->format(DateTime::ATOM) : ''; |
||
| 1401 | }; |
||
| 1402 | |||
| 1403 | $defaultContext = [ |
||
| 1404 | AbstractNormalizer::CALLBACKS => [ |
||
| 1405 | 'createdAt' => $callback, |
||
| 1406 | 'lastLogin' => $callback, |
||
| 1407 | 'registrationDate' => $callback, |
||
| 1408 | 'memberSince' => $callback, |
||
| 1409 | ], |
||
| 1410 | AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) { |
||
| 1411 | return get_class($object); |
||
| 1412 | }, |
||
| 1413 | ]; |
||
| 1414 | |||
| 1415 | $normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext); |
||
| 1416 | $serializer = new Serializer( |
||
| 1417 | [$normalizer], |
||
| 1418 | [new JsonEncoder()] |
||
| 1419 | ); |
||
| 1420 | |||
| 1421 | return $serializer->serialize($user, 'json', [ |
||
| 1422 | AbstractNormalizer::IGNORED_ATTRIBUTES => $ignore, |
||
| 1423 | ]); |
||
| 1499 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.