7 days of WordPress plugins, themes & templates - for free!* Unlimited asset downloads! Start 7-Day Free Trial

Next lesson playing in 5 seconds

  • Overview
  • Transcript

3.1 The Core Classes

Ok, we've covered a lot of background information. In this lesson, we'll start getting more hands-on: looking at the core classes which we'll use and build on.

3.1 The Core Classes

Okay, we've covered a lot of background information so far. Now, let's start getting more hands on by looking at the core classes which we'll use and build on as well as start fleshing out the code. Firstly, let's look at the Episode value object. This is located in src/PodcastSite/Entity/Episode.php. This is the object which will be hydrated from an Episode data file. You can see that it's a simple class which doesn't extend any others nor implement any interfaces. It has a series of protected properties which roughly match the properties in the data file we saw earlier. Those being publish date, slug, title, content, link, download, guests, and so on. The constructor allows for the initialization of all properties by iterating over an array or iterator and setting the property if it's found in the supplied data. Then we have a series of getter methods which just return the unchanged property values. Now let's have another quick look at the data file, which you can find at storage/posts/episode-0001.md. You can see in the ML front matter that we set the publish date, slug, title, file size and file type, duration, and so on. Then in the body, you can see that we store the show synopsis, related links, author bio, and so on. This presents us though with our first challenge. What we wanna do is iterate over the post directory. Which reading only the markdown files, which aren't empty. Said another way, or looking at a specific example, we need to avoid dot files, which, if you're familiar with Linux or Unix based operating systems. These are the directories which point to the current directory and the parent of the current directory. And on top of that, we also need to filter out symlinks and any other type of file which may be present, as well as not traverse any directory inside the current directory. That's it for this video, in the next video, we'll start working through the class which have traits or the episode data from the markdown data files.

Back to the top