setting name via config array#672
setting name via config array#672janschoenherr wants to merge 1 commit intojoomla:stagingfrom janschoenherr:patch-2
Conversation
…mplate search path might be wrong.
|
Unit testing complete. There were 0 failures and 0 errors from 1971 tests and 11142 assertions. |
|
Could you propose a solution that include the test on empty($this->_name) ? ie: |
|
Shouldn't it always be empty? It's in the constructor. |
|
It could have been set in the declaration of the class |
|
The actual issue is that $this->name has been introduced without wiring it up. Is _name supposed to be private or protected? Either way we should use it the way we want to use it in the long term and use __set() and __get() for b/c for 2.5. |
|
Trying to implement a Looking at $name and $_name, turns out that both are in use but $name has never been declared: <?php
class JView extends JObject
{
public function __construct($config = array())
{
// Set the view name
if (empty($this->_name))
{
if (array_key_exists('name', $config))
{
$this->_name = $config['name'];
}
else
{
$this->_name = $this->getName();
}
}
...
}
public function getName()
{
if (empty($this->name))
{
$r = null;
if (!preg_match('/View((view)*(.*(view)?.*))$/i', get_class($this), $r))
{
JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME'));
}
if (strpos($r[3], "view"))
{
JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME_SUBSTRING'));
}
$this->name = strtolower($r[3]);
}
return $this->name;
}
}So there is definitely something more here. @janschoenherr Could you give an example of
? |
|
@elkuku sure: If I create an instance of a subclass of JView
and pass the constructor an array with the name
the constructor of JView sets
then continues to
and here it calls
this returns empty, because $this->name is not set yet and the name is not being retrieved from the class name. You'll end up with something like
but expect something like
|
|
This has been fixed in #1144 in a different way. Thanks for contributing! |
Hi,
it would be nice to set the name via config. Otherwise the default template search path might be wrong.
Regards