Introduction to Interfaces

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:04
    Notice AbstractShip storage, unlike AbstractShip,
  • 0:08
    doesn't actually have any logic in it.
  • 0:11
    All it does is have a contract
  • 0:14
    that guarantees anything that extends this
  • 0:17
    has these two functions.
  • 0:19
    It turns out that when you have an abstract class like this
  • 0:22
    that only contains abstract functions
  • 0:25
    and no real code, well,
  • 0:27
    it's the perfect opportunity to use an interface.
  • 0:30
    An interface works just like an abstract class
Loading ...

Introduction to Interfaces

Loading...

We have an abstract class with methods that we require, but there’s no logic in these abstract methods. This is a perfect opportunity to use interfaces. In this tutorial, I will show you how to create and implement Interfaces. I will also explain how interfaces are useful when you will be sharing your code. But even if you’re not creating interfaces to share, chances are, if you’re using open source code — and definitely in Drupal 8 — you will need to know how to implement interfaces.

Downloads: 
Log in or sign up to download companion files.
Additional resources: