User tests: Successful: Unsuccessful:
One way that we could dynamically create a table and key for getting an instance without needing to set up your own JTable class
Title |
|
Title |
|
||||||
Labels |
Added:
?
?
|
Title |
|
Title |
|
||||||
Description | ⇒ | <p>One way that we could dynamically create a table and key for getting an instance without needing to set up your own JTable class</p> |
Status | New | ⇒ | Pending |
Labels |
Removed:
?
|
Category | ⇒ | Libraries |
Status | Pending | ⇒ | Information Required |
Ahh it was part of an RFC in https://groups.google.com/forum/#!searchin/joomla-dev-cms/table/joomla-dev-cms/AiCOgamjQvQ/yHw_QC4JfM4J which is why explanations are poor. It's a developer feature rather than a user feature. So testing is also pretty hard.
especially without any description;)
So can it be closed?
On 6 March 2015 at 00:43, George Wilson notifications@github.com wrote:
Ahh it was part of an RFC in
https://groups.google.com/forum/#!searchin/joomla-dev-cms/table/joomla-dev-cms/AiCOgamjQvQ/yHw_QC4JfM4J
which is why explanations are poor. It's a developer feature rather than a
user feature. So testing is also pretty hard.—
Reply to this email directly or view it on GitHub
#3483 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
Please don't. I just need the time to reraise it. There were a few recommendations that I had that need tweaking as well.
Labels |
Added:
?
|
It's great to see ideas that I implemented in the very first versions of Nooku making their way into the core. The goal of Nooku has always been to allow developers to do more with less code.
Remove the coupling with the FOF::Inflector(). If the Joomla inflector cannot handle what you need it to do, it would be better to optimise the Joomla\String\Inflector. This also reduced dependency on FOF.
The logic you added to find the table name and keyname belongs in the constructor of JTable, not in JTable::getInstance(). getInstance() is a factory method it's sole purpose following the 'factory method design pattern' is to discover the classname and instantiate the object. Configuration of the object should happen during object construction, not before.
Other then that the code suggested is a good addition and will make it easier to instantiate table objects on the fly for any database table that follows naming conventions. It also helps to establish conventions for developers.
The concept you use here is what I did in very early versions of Nooku back in 2007. I further improved upon this by making the objects aware of their own identity using the information in the classname. In early versions (today this has evolved into a Identifier metaobject) of Nooku each object had a getIdentifier() method that returns component name and object name, for example
FooTableBars
Would return
$component = $this->getIdentifier()->component; -> foo
$type = $this->getIdentifier()->type; -> table
$name = $this->getIdentifier()->name -> bars
Based on that information you can then easily create the table name and primary key.
table = '#__'.$component.'_'.$name
key = '#__'.$component.'_'.toSingular($name)
A getIdentifier() could be implemented using a Trait, which would make it easy to retrofit the codebase and slowly bring in naming based conventions as you did here for table names.
Final note, the primary key is merely a naming convention, you can get the primary key information from the database table metadata too.
Category | Libraries | ⇒ | Feature Request Libraries |
Hello @wilsonge
Thank you for your contribution.
The last comment here was on July 8th. So the question is, Are you planning to work on this in the near future? If not, please close and re-open when you are ready to work on it.
If no reply is received within 4 weeks we will close this issue.
Thanks for understanding!
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-11-08 17:40:09 |
Closed_By | ⇒ | wilsonge |
@wilsonge This is almost 1 year old with absolutely no comments at all (probably because of the complete lack of any meaningful explanation) can this just be closed
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3483.