Simple Factory Pattern Demo (ok)
Hoặc viết dưới dạng plugin
This project was written as a demo application for an Envato Tuts+ Series on using Design Patterns in WordPress.
This project is not an official WordPress plugin, theme, or application and is not meant to be run within the context of the WordPress application.
It's meant to provide a working example of the Simple Factory design pattern.
File Contents
demo.php
is the driver that is meant to be the entry-point of the application. It sets everything into motion.images
contains a sketch of the Simple Factory Pattern diagram for this demolib
contains the core files for the applicationlib/plugin.php
represents the core plugin file or, more specifically, how you would incorporate the Simple Factory into a WordPress plugin.lib/simple-factory.php
is the Simple Factory class itself that relies on a base class, its subclasses, and input to return the proper elementlib/users/user.php
the abstract base class representing all userslib/users/admin.php
the subclass representing an Adminstrator withread-write
privilegeslib/users/reader.php
the subclass representing a Reader withread
privilegeslib/users/volunteer.php
the subclass representing a Volunteer withhelp
privileges*
Installation
Download a copy of the latest tag from GitHub
Extract the contents to a directory of your choice
Run the
demo.php
script from the command-line to see the script in action
Last updated