forked from nestauk/DSI4EU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.php
131 lines (118 loc) · 12.2 KB
/
cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
use \DSI\Service\Translate;
use \DSI\Entity\Translation;
require __DIR__ . '/src/config.php';
class CliRouter
{
/** @var array[] */
private $routes;
public function __construct()
{
$this->addRoute('cities-to-geolocation', function () {
$command = new \DSI\Controller\CLI\CitiesToGeolocationController();
$command->exec();
});
$this->addRoute('delete-spam-organisations', function () {
$spamIDs = [2011, 2029, 2112, 2058, 1248, 1972, 1973, 2004, 2059, 890, 2077, 2015, 2089, 1994, 1990, 2092, 2114, 2042, 2090, 2091, 2117, 2094, 2035, 142, 356, 2060, 2106, 2064, 2065, 2107, 2073, 2020, 2045, 2034, 2061, 2062, 2046, 63, 2118, 282, 2078, 1230, 2074, 2005, 1993, 1328, 260, 2113, 2002, 2082, 1256, 2079, 2052, 2043, 1322, 2039, 2021];
$executor = (new \DSI\Repository\UserRepo())->getById(1);
foreach ($spamIDs AS $spamID) {
try {
$command = new \DSI\UseCase\Organisations\RemoveOrganisation();
$command->data()->executor = $executor;
$command->data()->organisation = (new \DSI\Repository\OrganisationRepo())
->getById($spamID);
$command->exec();
echo "Organisation {$spamID} deleted" . PHP_EOL;
} catch (\DSI\NotFound $e) {
echo "Organisation {$spamID} not found" . PHP_EOL;
}
}
});
$this->addRoute('delete-spam-projects', function () {
$spamIDs = [1779, 2571, 2355, 1842, 2376, 2549, 2154, 368, 2112, 1828, 1995, 2027, 2494, 1186, 1826, 1777, 2541, 424, 1821, 1335, 2427, 847, 1965, 1848, 2257, 1601, 2288, 1541, 2161, 2460, 2550, 2551, 1695, 1723, 1724, 1704, 1163, 1160, 1161, 1162, 1756, 940, 1289, 1972, 2273, 2064, 1334, 1999, 2334, 1365, 1982, 2005, 2317, 1932, 1934, 2118, 2544, 2459, 1301, 2443, 1359, 2567, 1959, 2387, 2036, 1850, 834, 1529, 1427, 2269, 1144, 1451, 2465, 1336, 2492, 937, 2199, 2216, 1409, 1420, 1991, 1387, 2315, 2381, 2003, 2194, 1960, 2157, 1872, 2566, 2097, 2265, 2099, 2171, 1796, 2437, 1570, 1579, 1396, 1305, 299, 1803, 1665, 929, 1139, 2559, 1636, 2298, 1727, 1628, 2169, 1958, 1569, 1263, 1565, 8, 2542, 2167, 1514, 1218, 1688, 865, 1562, 1311, 1559, 1884, 2192, 1491, 1903, 2166, 1689, 1369, 2340, 1774, 1775, 2390, 2121, 1523, 2119, 1528, 1517, 1967, 2418, 2425, 1258, 1535, 875, 1790, 1594, 1582, 1895, 1588, 1666, 1892, 1894, 1668, 773, 2470, 1319, 1363, 2337, 1322, 672, 261, 2518, 2336, 2170, 2479, 2480, 2481, 1580, 2380, 1925, 1534, 1539, 933, 1242, 2515, 780, 2535, 1241, 2363, 2197, 2220, 2198, 2208, 1854, 1853, 2200, 2450, 1508, 1984, 1985, 2151, 2587, 1900, 1574, 2343, 2506, 2576, 2466, 2548, 2547, 1203, 2495, 2204, 2332, 2132, 1882, 1878, 2341, 2537, 2383, 2385, 2187, 2278, 2283, 1155, 164, 830, 1259, 1300, 1394, 2511, 2106, 1403, 1398, 1344, 1645, 2577, 1496, 1500, 1540, 1881, 1550, 60, 1852, 949, 537, 2338, 1521, 1525, 1808, 1462, 2408, 2455, 1705, 1357, 1512, 1382, 1383, 1196, 2482, 2483, 1119, 1473, 2282, 2280, 1230, 555, 2172, 2039, 2497, 350, 502, 123, 2250, 1510, 1737, 2353, 2116, 1443, 2311, 2042, 2267, 2004, 1264, 2560, 1226, 2310, 1545, 2402, 2409, 1885, 1542, 1537, 2405, 2406, 2312, 2410, 855, 1516, 1812, 2473, 2474, 2475, 1406, 2178, 2293, 2513, 2514, 2224, 2512, 1764, 1180, 827, 1331, 1547, 2401, 1610, 1170, 2268, 1407, 2313, 2588, 1927, 2076, 1618, 1859, 2037, 1479, 1204, 1974, 1976, 2290, 1506, 289, 2072, 1280, 1339, 2179, 2057, 1513, 2235, 1378, 935, 2111, 1400, 1917, 1461, 1946, 1712, 2184, 2185, 2275, 1613, 1681, 1682, 1683, 1686, 2077, 2193, 2323, 2324, 2325, 880, 2285, 1571, 944, 2246, 1760, 2364, 2068, 1317, 1117, 2253, 2254, 2196, 1499, 256, 1327, 1274, 1902, 2501, 1918, 2335, 2499, 1374, 1615, 1527, 2218, 1312, 1315, 1433, 1428, 1596, 1714, 1193, 1213, 1214, 2297, 2403, 2034, 1296, 1635, 2417, 2165, 2530, 1432, 1115, 2384, 1546, 1987, 1417, 246, 2517, 2528, 680, 1634, 1338, 1519, 1986, 2041, 2081, 1554, 2447, 2271, 1603, 1623, 1624, 2572, 2426, 2279, 2428, 1741, 2305, 2589, 1223, 1245, 1143, 1654, 2000, 1133, 2476, 1734, 2017, 2018, 1384, 2058, 2377, 1314, 2509, 1924, 2449, 1966, 1942, 885, 1715, 1200, 1201, 1460, 2543, 2496, 1701, 1993, 1207, 2262, 1278, 190, 1231, 1649, 2098, 2100, 1700, 2568, 1442, 1449, 1441, 2342, 1435, 1429, 1676, 2299, 1342, 2120, 1222, 1485, 2472, 2471, 1722, 2519, 1823, 1346, 2349, 2055, 2217, 1131, 1938, 931, 1898, 1899, 1589, 1593, 1600, 2557, 2555, 1620, 1294, 2441, 2438, 2439, 2440, 1022, 1846, 2367, 2369, 1834, 1832, 2211, 2221, 1266, 1237, 1721, 2488, 1968, 2327, 2026, 2322, 1996, 1770, 950, 2002, 1298, 2006, 1765, 1464, 2388, 2391, 2105, 2142, 2011, 2346, 2562, 2581, 2489, 1282, 2069, 2350, 1292, 1670, 1595, 306, 2125, 2230, 1586, 2225, 1459, 1837, 1800, 1862, 2561, 2339, 2534, 2563, 2580, 2304, 2143, 924, 1121, 1901, 1829, 1752, 1233, 1888, 2366, 2395, 1798, 2316, 2079, 2078, 2554, 1825, 1729, 1990, 2261, 1768, 2294, 1742, 1755, 1713, 1205, 1744, 1375, 2228, 1687, 1566, 1641, 1240, 1221, 602, 1544, 1532, 451, 1505, 888, 890, 1921, 704, 1220, 2411, 2412, 1933, 2059, 696, 2159, 2156, 637, 2504, 2245, 2407, 20, 1372, 1961, 2146, 2145, 1445, 1455, 2137, 2520, 2063, 1930, 2114, 1446, 1448, 2421, 1736, 1474, 1664, 1728, 1738, 2190, 1905, 2144, 2153, 2379, 2053, 2300, 1950, 2358, 1809, 1810, 2584, 2442, 2094, 2398, 1847, 2020, 869, 1356, 1279, 2582, 1661, 2247, 139, 1416, 914, 1295, 1340, 1341, 2491, 2149, 2073, 2182, 1484, 2274, 2152, 1480, 2259, 1735, 1502, 695, 1137, 1150, 1151, 892, 1321, 1910, 2148, 2191, 1875, 1877, 1202, 1195, 2134, 1402, 1401, 1397, 2436, 1306, 1801, 1481, 2445, 1879, 2272, 1548, 2174, 2139, 2593, 2467, 1937, 1844, 1841, 2074, 1271, 1869, 2140, 2141, 2558, 2277, 2348, 1288, 943, 1669, 1969, 1114, 1611, 1332, 912, 1679, 2319, 2578, 2213, 2013, 1851, 1662, 2109, 1922, 1590, 2378, 2485, 2404, 1612, 2103, 1606, 2374, 1690, 1693, 1936, 1607, 2237, 2486, 1371, 972, 1908, 1773, 2371, 1482, 2368, 2345, 1395, 1509, 2158, 1489, 1716, 202, 2117, 2091, 1992, 2087, 2088, 1817, 1379, 1424, 1627, 2490, 2060, 1970, 1390, 1388, 1389, 1380, 1971, 1243, 1328, 1538, 2505, 2536, 1718, 2423, 385, 1699, 2084, 2242, 2243, 266, 1050, 2028, 2525, 2451, 2468, 2454, 1839, 2422, 2344, 2022, 2023, 2244, 1511, 1761, 2015, 2487, 65, 2432, 939, 1361, 809, 1486, 1284, 1915, 2207, 1909, 2564, 2397, 1367, 216, 1663, 1667, 2463, 135, 1911, 2183, 2181, 2255, 2251, 1347, 1935, 2448, 2556, 2586, 2594, 1472, 1469, 2510, 2236, 2533, 1, 1916, 1831, 1148, 938, 1766, 1587, 1943, 2164, 2203, 2507, 2163, 1560, 1836, 2031, 2359, 2389, 2502, 2500, 2035, 1260, 1261, 1265, 2229, 2573, 2574, 1710, 2258, 954, 2524, 1804, 22, 2393, 1333, 1767, 2585, 1584, 1646, 1343, 1778, 1270, 948, 2032, 1307, 1983, 1134, 1135, 2025, 2030, 2357, 1351, 1255, 1673, 2429, 1639, 1644, 215, 792, 2195, 1348, 1350, 837, 1194, 2331, 2386, 2552, 2529, 2527, 2545, 916, 392, 2147, 618, 1177, 1807, 1757, 1758, 2493, 2135, 2484, 2347, 1940, 1647, 1648, 769, 2071, 983, 1165, 1585, 1815, 2392, 1751, 1868, 2113, 223, 1802, 1949, 1947, 1944, 856, 1561, 2276, 2080, 2054, 1536, 2503, 2086, 2047, 1142, 2075, 1953, 1954, 2231, 283, 226, 663, 145, 1501, 174, 1494, 2309, 1286, 1897, 2173, 222, 2532, 1671, 1672, 2284, 2252, 1904, 2301, 1381, 2569, 2382, 2238, 2306, 2302, 2281, 2307, 2249, 1323, 1454, 1880, 1797, 1856, 2372, 1626, 2508, 2330, 2591, 2320, 1576, 1608, 1602, 1981, 946, 1522, 1526, 898, 1748, 1153, 1674, 1675, 2021, 1437, 2001, 853, 1558, 1896, 1998, 842, 2090, 1980, 1957, 1951, 1471, 2122, 2123, 2124, 1617, 1912, 2539, 1684, 2089, 2107, 2232, 1931, 1466, 2061, 2056, 544, 1753, 1811, 1660, 2014, 1563, 2052, 2051, 2430, 2029, 1591, 376, 2375, 1806, 2102, 2104, 2175, 1488, 1490, 2136, 1430, 2291, 2289, 1413, 1625, 2446, 2329, 1781, 2333, 2321, 1786, 1622, 2575, 1173, 1444, 2008, 2009, 2295, 1553, 2553, 2361, 2162, 1475, 1313, 2248, 2546, 1923, 1988, 1609, 1604, 1239, 1324, 2326, 1740, 2096, 2101, 448, 1787, 2038, 2303, 1928, 2433, 1929, 1320, 2444, 2093, 2222, 2370, 2314, 2019, 1955, 1354, 1994, 1956, 1717, 958, 2050, 1229, 2048, 2049, 2415, 2287, 2160, 1175, 1283, 2214, 1408, 1414, 2201, 2024, 1366, 1364, 1127, 1181, 955, 795, 1827, 2373, 1843, 1997, 1337, 1720, 932, 1578, 2040, 1189, 78, 1232, 1977, 1784, 1783, 2521, 1614, 1771, 2522, 1605, 1154, 2227, 2233, 1822, 360, 1291, 2498, 273, 927, 1978, 1979, 2095, 1290, 1452, 1745, 1287, 1794, 1789, 1393, 2234, 1830, 1179, 1415, 1750, 1780, 1893, 2399, 1651, 1564, 2270, 1465, 1659, 907, 1733, 2033, 1975, 2092, 2431, 1492, 2308, 1302, 2420, 2469, 2400, 2010, 1423, 1285, 2462, 2127, 1680, 1439, 1438, 1616, 2570, 1621, 1412, 1864, 2155, 1858, 1860, 1863, 1989, 1573, 1235, 1883, 2070, 186, 1167, 1168, 2590, 1963, 1964, 945, 1329, 2263, 2365, 1730, 1731, 1326, 1891, 2168, 1345, 2045, 2115, 1952, 2150, 1709, 1711, 1125, 2046, 2478, 1217, 1692, 1785, 2180, 2188, 2189, 1816, 2126, 2292, 1228, 2538, 1330, 2186, 1833, 2424, 2419, 962, 1769, 1642, 149, 1638, 952, 1377, 729, 1762, 2082, 2083, 1551, 2579, 19, 911, 2531, 900, 514, 1309, 1719, 826, 1913, 1907, 2226, 908];
$executor = (new \DSI\Repository\UserRepo())->getById(1);
foreach ($spamIDs AS $spamID) {
try {
$command = new \DSI\UseCase\Projects\RemoveProject();
$command->data()->executor = $executor;
$command->data()->project = (new \DSI\Repository\ProjectRepo())
->getById($spamID);
$command->exec();
echo "Project {$spamID} deleted" . PHP_EOL;
} catch (\DSI\NotFound $e) {
echo "Project {$spamID} not found" . PHP_EOL;
}
}
});
$this->addRoute('import-user-project-organisation-links', function () {
$command = new \DSI\Controller\CLI\ImportUserProjectOrganisationLinkController();
$command->exec();
});
$this->addRoute('import-organisations', function () {
$command = new \DSI\Controller\CLI\ImportOrganisationsController();
$command->exec();
});
$this->addRoute('import-organisation-urls', function () {
$command = new \DSI\Controller\CLI\ImportOrgLinksController();
$command->exec();
});
$this->addRoute('import-projects', function () {
$command = new \DSI\Controller\CLI\ImportProjectsController();
$command->exec();
});
$this->addRoute('send-cached-emails', function () {
$command = new \DSI\Controller\CLI\SendCachedEmailsController();
$command->exec();
});
$this->addRoute('update-organisations-partners-count', function () {
$command = new \DSI\Controller\CLI\UpdateOrganisationsPartnersCountController();
$command->exec();
});
$this->addRoute('update-project-tags', function ($args) {
$command = new \DSI\Controller\CLI\UpdateProjectTagsController();
$command->setArgs($args);
$command->exec();
});
$this->addRoute('update-project-tech-tags', function ($args) {
$command = new \DSI\Controller\CLI\UpdateProjectTechTagsController();
$command->setArgs($args);
$command->exec();
});
$this->addRoute('send-waiting-approval', function ($args) {
$command = new \DSI\Controller\CLI\SendWaitingApprovalController();
$command->setArgs($args);
$command->exec();
});
}
public function exec($args)
{
Translate::setCurrentLang(Translation::DEFAULT_LANGUAGE);
if (!isset($args[1])) {
echo 'Valid routes: ' . PHP_EOL;
foreach ($this->routes AS $route) {
echo $route[0] . PHP_EOL;
}
return;
}
foreach ($this->routes AS $route) {
if ($args[1] === $route[0]) {
$route[1]($args);
return;
}
}
echo 'Invalid argument: ' . $args[1] . PHP_EOL;
foreach ($this->routes AS $route) {
echo $route[0] . PHP_EOL;
}
return;
}
private function addRoute($arg0, $handle)
{
$this->routes[] = [
$arg0,
$handle
];
}
}
$router = new CliRouter();
$router->exec($argv);