The context:
I am currently struggling with a conception problem: I am building a SEO tags generator in PHP. I already managed to render some beautiful tags like these:
<meta name="keywords" content="look, at, my, horse" />
<meta property="og:title" content="My horse is amazing" />
<meta http-equiv="Cache-Control" content="no-cache" />
<link type="application/rss+xml" rel="alternate" title="RSS" href="http://feeds.feedburner.com/martini" />
<link type="application/json" href="http://facebook.com/leogout.json" />
Which are represented like this in my model:
They are then manipulated with some builders:
In the render() method, they iterates over their collections of tags and renders every tags + concat them together in a big pile of... HTML.
If there are already some OOP problems or misconceptions, don't hesitate to give me some advice about them too !
The problem:
So far so good, now I have to render an unique <title><title/>
tag.
I added a TitleTag
to the model and a TitleTagBuilder
like this:
Aaah I need more than 10 reputation to post more links :S Well...
+------------------+
|TagBuilderInterface
+------------------+
^
|
+------------------+
|AbstractTagBuilder|
+------------------+
+-----------------^ ^ ^------------------+
| | |
| | |
| | |
+-------------------+ +------------------+ +-----------------------+
|MetaTagBuilder | |LinkTagBuilder | |TitleTagBuilder (NEW!) |
+-------------------+ +------------------+ +-----------------------+
But now what can I do with my AbstractTagBuilder ? It only knows how to render a collection of tags, but I don't think it's a good thing that users can add multiple <title>
tags to their web pages. Should I create an AbstractUniqueTagBuilder
or something ? How would you solve this problem ?
Thanks for your time.
PS: The diagrams are generated with PhpStorm except for the last one which is generated with asciiflow (can't post the link either...) in case you were wondering :)