WebDevStudios / oops-wp

A collection of abstract classes, interfaces, and traits to promote object-oriented programming practices in WordPress.
57 stars 9 forks source link

PostType class should throw an exception if $slug is not defined. #17

Open jmichaelward opened 5 years ago

jmichaelward commented 5 years ago

PostType objects do not currently throw an exception if a $slug property is not defined, which can be confusing to developers when trying to extend the PostType class.

The Taxonomy class runs a requirements check before attempting to register a taxonomy, which alerts developers if the $slug or $object_types properties are missing. That implementation probably needs a little work (clearly the conditional in the register method there never actually passes if an exception is thrown), but it could serve as a model for how to address this missing exceptions in the PostType class. See: https://github.com/WebDevStudios/oops-wp/blob/master/src/Structure/Content/Taxonomy.php#L53

oddevan commented 4 years ago

Looking at this as I'm also looking to add some content types soon.

Do we want to use the generic \Exception like the Taxonomy class is, or do we want to create some specialized exceptions?