IteratorAggregate: Loop Over an Object

Video loading...

Transcripts: 
Transcript language code: 
eng

Join Drupalize.Me to watch this video

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

Log in Sign up
  • 0:07
    Let me show you just one other really cool magic thing,
  • 0:12
    this is my favorite.
  • 0:14
    Right now in ShipLoader, the getShips method returns an array.
  • 0:18
    Instead of doing that I'm going to return an object, a ship collection object.
  • 0:25
    Don't ask why yet, I'll show you some reasons in a minute.
  • 0:30
    First, create a new PHP Class called ShipCollection.
  • 0:34
    Hey, check it out, PhpStorm already correctly guessed that
  • 0:39
    this should have the Model namespace.
  • 0:41
    It understands our PSR-0 naming convention.
  • 0:46
    Inside, add a private ships property,
Loading ...

IteratorAggregate: Loop Over an Object

Loading...

In this tutorial, learn how to implement PHP's built-in interface IteratorAggregate to loop over an object.

Downloads: 
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.