oops-wp icon indicating copy to clipboard operation
oops-wp copied to clipboard

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

Open jmichaelward opened this issue 6 years ago • 1 comments

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

jmichaelward avatar May 01 '19 13:05 jmichaelward

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?

oddevan avatar Feb 28 '20 15:02 oddevan