51
18 April Meetup

18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

18 April Meetup

Page 2: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Yet Another v8 TalkStéphane Gay

Architect At Large. Chief refactor-er & bug fixer bij Umbraco HQ

@zpqrtbnk

Page 3: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

v8 is LIVE… and it works …

Page 4: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

8.365.112 SITES

Could be running Umbraco v8 in a distant future,provided that all other CMSes give up the fightand Umbraco becomes the only remaining CMS

(number may vary)

Page 5: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

v8 goed gedaanStéphane Gay

Repairman Of All Things Completely Broken™Umbraco HQ

@zpqrtbnk

Page 6: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Variants101

Page 7: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

One Document – Several Cultures

Page 8: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

DocumentFR: "bonjour" ⟶ /bonjourEN: "hello" ⟶ /hello

Page 9: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

DocumentFR: "bonjour" ⟶ /fr/bonjourEN: "hello" ⟶ /en/hello

example.com/fr ⟶ FRexample.com/en ⟶ EN

Page 10: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

var title = Model.Value("title");

var title = Model.Value("title", "fr-FR");

Page 11: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Composition~

Page 12: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Dependency Injection

Page 13: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

ComposerWhere Everything Begins

Page 14: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public class MyComposer : IComposer{

public void Compose(Composition composition){

// ...}

}

Page 15: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

// set the last chance content findercomposition.SetContentLastChanceFinder<MyLastChanceFinder>();

// append a finder to the pipelinecomposition.ContentFinders().Append<MyContentFinder>();

Page 16: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

// registercomposition.Register<ISomething, Something>();

Page 17: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

// registercomposition.RegisterFor<ISomething, Something>();

Page 18: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Predictable CompositionLess Magic

Page 19: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

[RuntimeLevel(MinLevel = RuntimeLevel.Install)][ComposeAfter(typeof(MyOtherComposer))][Disable(typeof(OtherComposer))]public class MyComposer : IUserComposer{

public void Compose(Composition composition){

// ...}

}

Page 20: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

ComponentBring Your Own Code

Page 21: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public class MyComponent : IComponent{

public void Initialize(){

// ...}

public void Terminate(){

// ...}

}

Page 22: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public class MyComponent : IComponent{

private readonly IContentService _contentService;

public MyComponent(IContentService contentService){

_contentService = contentService;}

Page 23: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public void Compose(Composition composition){

composition.Components().Append<MyComponent>();}

Page 24: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 25: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 26: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

ContextIs Everything

Page 27: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

private readonly IUmbracoContextFactory _contextFactory;

public MyComponent(IUmbracoContextFactory contextFactory){

_contextFactory = contextFactory;}

public void Initialize(){

using (var contextRef = _contextFactory.EnsureUmbracoContext()){

var context = contextRef.UmbracoContext;

// ...var item = context.ContentCache.GetById(1234);

}}

Page 28: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 29: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

The DatabaseWhere ?!

Page 30: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Use The ScopeLuke

Page 31: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

private readonly IScopeProvider _scopeProvider;

public MyComponent(IScopeProvider scopeProvider){

_scopeProvider = scopeProvider;}

public void Initialize(){

using (var scope = _scopeProvider.CreateScope()){

scope.Database.Execute("DELETE * FROM umbracoNode;");

scope.Complete();}

}

Page 32: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

DI.Die.Die.DieI Don't Wanna DI

Page 33: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public void Whatever(){

Current.Logger.Debug<MyClass>("Hello!");}

Page 34: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public void Whatever(){

var service = Current.Factory.GetInstance<IMyService>();}

Page 35: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Published ElementsLightweight Published Content

Page 36: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

MigrationsPlan

Page 37: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 38: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

public class MyPlan : MigrationPlan{

public MyPlan(): base("myPlan")

{From("")

.To<MyMigration1>("state-1")

.To<MyMigration2>("state-2");}

Page 39: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 40: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM
Page 41: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

....To<MyMigration2>("state-2").Merge()

.To<Dev1Migration>("dev-1-state").With()

.To<Dev2Migration>("dev-2-state").As("state-3");

Page 42: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

var plan = new MyPlan();var upgrader = new Upgrader(plan);upgrader.Upgrade(...);

Page 43: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Migrating From v7Have You Found The Way?

Page 44: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

One More ThingWhat Is Next?

Page 45: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

var title = Model.Value("title");

var title = Model.Value("title", "fr-FR");

Page 46: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

// use the propertyvar children = Model.Children;

// use the methodvar children = Model.Children();

// use the method, with a culturevar children = Model.Children("fr-FR");

Page 47: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

// current culturevar name = Model.Name;

// FR culturevar nameFR = Model.GetCulture("fr-FR").Name;

// Can I has this?var nameFR = Model.Name("fr-FR");

Page 48: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Fixing Is Breaking

Page 49: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

The Friendliest CMS Community On The PlanetMake sure to voice your opinionIssues are monitored

Get what you want!

Page 50: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Thank you

Page 51: 18 April Meetup - ZpqrtBnk · 18 April Meetup. Yet Another v8 Talk. St. ... Présentation PowerPoint Created Date: 4/19/2019 6:07:49 PM

Thanks!