Uncategorized

Updating the Search API to D8 – Part 1: Creating an entity type

TL; DR:

The 8.x version of Drupal has entered Alpha stage and people everywhere are telling you to port your modules now. However, proper documentation is scarce and existing tutorials or examples only explain the simplest steps. Bad for modules like the Search API, which define new entity types and plugins and aren’t as easy to port.
Still, I decided to venture into the unknown and start porting now. It was about as bad as I’d feared and I’m still far, far from finished, but I nevertheless wanted to share the first advanced pieces of updating wisdom I’ve found. Hopefully it will help others get started more smoothly than I did.

Where to start

So, you’ve decided to port your complex module (which, e.g., lets you take your pant entities off) to D8. Great! But where to start?
Of course, there’s the much-praise list of change records. A quick glance will tell you that there’s currently 464 entries in there – so better close that tab again and move on. (The search is also very bad, as it finds everything and sorts it by date instead of relevance. So even if you know something has changed (e.g., the entity system) and just need information on that, it’s rather hard to find it. It will also be mostly spread across multiple records.)
The documentation is surprisingly detailed and up-to-date in some areas (e.g., Plugins) and as out-of-date and monosyllabic as you’d fear in others (e.g., entities), so it’s really a hit-or-miss there. If you’re looking for something, try to find it in change records or the documentation first, but prepare for the possibility that you’ll have to resort to the surest, but also most exhausting option: digging through core code and seeing how they do it.

Caveat

Before I start, a word of caution which probably isn’t necessary: the whole D8 code is still very much in flux, so everything is volatile and very much subject to change. I myself expect to have to revisit much of what I talk about here to adapt it to upcoming core changes (not that I’m even trying to keep track of them beforehand). Especially since the entity system seems to be among the particularly volatile, as some things simply don’t work right now, others aren’t very elegant and there seem to be three versions of entities (a backwards-compatibility (BC) layer, “normal” entities and something by the name of EntityNG). I’m curious what they’ll come up with there, in the end.

Creating an entity type in D8

So, let’s get started! How to create a new entity type …

Different kinds of entities

First off, you’ll have to decide what kind of entity you want: content entities, like nodes or users, are typically stored in the database, same as D7 entities. They should be used for content which usually isn’t deployed from a staging server but can be created in any amount on the production site. Configuration entities, on the other hand, integrate with the new configuration system in D8 and can thus be easily deployed from a staging environment to a production site. Use these, therefore, for entities which are basically site configuration – blocks or content types are good examples here.

 

Read More 2001
Read More 2002
Read More 2003
Read More 2004
Read More 2005
Read More 2006
Read More 2007
Read More 2008
Read More 2009
Read More 2010
Read More 2011
Read More 2012
Read More 2013
Read More 2014
Read More 2015
Read More 2016
Read More 2017
Read More 2018
Read More 2019
Read More 2020
Read More 2021
Read More 2022
Read More 2023
Read More 2024
Read More 2025
Read More 2026
Read More 2027
Read More 2028
Read More 2029
Read More 2030
Read More 2031
Read More 2032
Read More 2033
Read More 2034
Read More 2035
Read More 2036
Read More 2037
Read More 2038
Read More 2039
Read More 2040
Read More 2041
Read More 2042
Read More 2043
Read More 2044
Read More 2045
Read More 2046
Read More 2047
Read More 2048
Read More 2049
Read More 2050
Read More 2051
Read More 2052
Read More 2053
Read More 2054
Read More 2055
Read More 2056
Read More 2057
Read More 2058
Read More 2059
Read More 2060
Read More 2061
Read More 2062
Read More 2063
Read More 2064
Read More 2065
Read More 2066
Read More 2067
Read More 2068
Read More 2069
Read More 2070
Read More 2071
Read More 2072
Read More 2073
Read More 2074
Read More 2075
Read More 2076
Read More 2077
Read More 2078
Read More 2079
Read More 2080
Read More 2081
Read More 2082
Read More 2083
Read More 2084
Read More 2085
Read More 2086
Read More 2087
Read More 2088
Read More 2089
Read More 2090
Read More 2091
Read More 2092
Read More 2093
Read More 2094
Read More 2095
Read More 2096
Read More 2097
Read More 2098
Read More 2099
Read More 2100
Read More 2101
Read More 2102
Read More 2103
Read More 2104
Read More 2105
Read More 2106
Read More 2107
Read More 2108
Read More 2109
Read More 2110
Read More 2111
Read More 2112
Read More 2113
Read More 2114
Read More 2115
Read More 2116
Read More 2117
Read More 2118
Read More 2119
Read More 2120
Read More 2121
Read More 2122
Read More 2123
Read More 2124
Read More 2125
Read More 2126
Read More 2127
Read More 2128
Read More 2129
Read More 2130
Read More 2131
Read More 2132
Read More 2133
Read More 2134
Read More 2135
Read More 2136
Read More 2137
Read More 2138
Read More 2139
Read More 2140
Read More 2141
Read More 2142
Read More 2143
Read More 2144
Read More 2145
Read More 2146
Read More 2147
Read More 2148
Read More 2149
Read More 2150
Read More 2151
Read More 2152
Read More 2153
Read More 2154
Read More 2155
Read More 2156
Read More 2157
Read More 2158
Read More 2159
Read More 2160
Read More 2161
Read More 2162
Read More 2163
Read More 2164
Read More 2165
Read More 2166
Read More 2167
Read More 2168
Read More 2169
Read More 2170
Read More 2171
Read More 2172
Read More 2173
Read More 2174
Read More 2175
Read More 2176
Read More 2177
Read More 2178
Read More 2179
Read More 2180
Read More 2181
Read More 2182
Read More 2183
Read More 2184
Read More 2185
Read More 2186
Read More 2187
Read More 2188
Read More 2189
Read More 2190
Read More 2191
Read More 2192
Read More 2193
Read More 2194
Read More 2195
Read More 2196
Read More 2197
Read More 2198
Read More 2199
Read More 2200
Read More 2201
Read More 2202
Read More 2203
Read More 2204
Read More 2205
Read More 2206
Read More 2207
Read More 2208
Read More 2209
Read More 2210
Read More 2211
Read More 2212
Read More 2213
Read More 2214
Read More 2215
Read More 2216
Read More 2217
Read More 2218
Read More 2219
Read More 2220
Read More 2221
Read More 2222
Read More 2223
Read More 2224
Read More 2225
Read More 2226
Read More 2227
Read More 2228
Read More 2229
Read More 2230
Read More 2231
Read More 2232
Read More 2233
Read More 2234
Read More 2235
Read More 2236
Read More 2237
Read More 2238
Read More 2239
Read More 2240
Read More 2241
Read More 2242
Read More 2243
Read More 2244
Read More 2245
Read More 2246
Read More 2247
Read More 2248
Read More 2249
Read More 2250
Read More 2251
Read More 2252
Read More 2253
Read More 2254
Read More 2255
Read More 2256
Read More 2257
Read More 2258
Read More 2259
Read More 2260
Read More 2261
Read More 2262
Read More 2263
Read More 2264
Read More 2265
Read More 2266
Read More 2267
Read More 2268
Read More 2269
Read More 2270
Read More 2271
Read More 2272
Read More 2273
Read More 2274
Read More 2275
Read More 2276
Read More 2277
Read More 2278
Read More 2279
Read More 2280
Read More 2281
Read More 2282
Read More 2283
Read More 2284
Read More 2285
Read More 2286
Read More 2287
Read More 2288
Read More 2289
Read More 2290
Read More 2291
Read More 2292
Read More 2293
Read More 2294
Read More 2295
Read More 2296
Read More 2297
Read More 2298
Read More 2299
Read More 2300
Read More 2301
Read More 2302
Read More 2303
Read More 2304
Read More 2305
Read More 2306
Read More 2307
Read More 2308
Read More 2309
Read More 2310
Read More 2311
Read More 2312
Read More 2313
Read More 2314
Read More 2315
Read More 2316
Read More 2317
Read More 2318
Read More 2319
Read More 2320
Read More 2321
Read More 2322
Read More 2323
Read More 2324
Read More 2325
Read More 2326
Read More 2327
Read More 2328
Read More 2329
Read More 2330
Read More 2331
Read More 2332
Read More 2333
Read More 2334
Read More 2335
Read More 2336
Read More 2337
Read More 2338
Read More 2339
Read More 2340
Read More 2341
Read More 2342
Read More 2343
Read More 2344
Read More 2345
Read More 2346
Read More 2347
Read More 2348
Read More 2349
Read More 2350
Read More 2351
Read More 2352
Read More 2353
Read More 2354
Read More 2355
Read More 2356
Read More 2357
Read More 2358
Read More 2359
Read More 2360
Read More 2361
Read More 2362
Read More 2363
Read More 2364
Read More 2365
Read More 2366
Read More 2367
Read More 2368
Read More 2369
Read More 2370
Read More 2371
Read More 2372
Read More 2373
Read More 2374
Read More 2375
Read More 2376
Read More 2377
Read More 2378
Read More 2379
Read More 2380
Read More 2381
Read More 2382
Read More 2383
Read More 2384
Read More 2385
Read More 2386
Read More 2387
Read More 2388
Read More 2389
Read More 2390
Read More 2391
Read More 2392
Read More 2393
Read More 2394
Read More 2395
Read More 2396
Read More 2397
Read More 2398
Read More 2399
Read More 2400
Read More 2401
Read More 2402
Read More 2403
Read More 2404
Read More 2405
Read More 2406
Read More 2407
Read More 2408
Read More 2409
Read More 2410
Read More 2411
Read More 2412
Read More 2413
Read More 2414
Read More 2415
Read More 2416
Read More 2417
Read More 2418
Read More 2419
Read More 2420
Read More 2421
Read More 2422
Read More 2423
Read More 2424
Read More 2425
Read More 2426
Read More 2427
Read More 2428
Read More 2429
Read More 2430
Read More 2431
Read More 2432
Read More 2433
Read More 2434
Read More 2435
Read More 2436
Read More 2437
Read More 2438
Read More 2439
Read More 2440
Read More 2441
Read More 2442
Read More 2443
Read More 2444
Read More 2445
Read More 2446
Read More 2447
Read More 2448
Read More 2449
Read More 2450
Read More 2451
Read More 2452
Read More 2453
Read More 2454
Read More 2455
Read More 2456
Read More 2457
Read More 2458
Read More 2459
Read More 2460
Read More 2461
Read More 2462
Read More 2463
Read More 2464
Read More 2465
Read More 2466
Read More 2467
Read More 2468
Read More 2469
Read More 2470
Read More 2471
Read More 2472
Read More 2473
Read More 2474
Read More 2475
Read More 2476
Read More 2477
Read More 2478
Read More 2479
Read More 2480
Read More 2481
Read More 2482
Read More 2483
Read More 2484
Read More 2485
Read More 2486
Read More 2487
Read More 2488
Read More 2489
Read More 2490
Read More 2491
Read More 2492
Read More 2493
Read More 2494
Read More 2495
Read More 2496
Read More 2497
Read More 2498
Read More 2499
Read More 2500

Related Articles

Leave a Reply

Back to top button