Traits: “Horizontal” Reuse

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

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

Log in Sign up
  • 0:07
    OK team, we need a new ship class, a bounty hunter ship.
  • 0:13
    Start simple, in the Model directory add a New Class,
  • 0:17
  • 0:19
    Once again, PhpStorm already added the correct namespace for us.
  • 0:25
    Like every other ship, extend AbstractShip.
  • 0:29
  • 0:30
    But we do not need a use statement for this.
  • 0:34
    That class lives in the same namespace as us.
  • 0:38
    Just like with an interface, when you extend an abstract class,
  • 0:41
    you usually need to implement some methods.
Loading ...

Traits: “Horizontal” Reuse


In this PHP tutorial, we'll introduce Traits in PHP and how you can utilize them to reuse your code.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.