Browse Source

Better naming for loadIfNot argument of Module::getModule and Module::getComponent

tags/2.0.0-beta
Alexander Makarov 13 years ago
parent
commit
b9a30b3024
  1. 12
      framework/base/Module.php

12
framework/base/Module.php

@ -201,17 +201,17 @@ abstract class Module extends Component implements Initable
/** /**
* Retrieves the named module. * Retrieves the named module.
* @param string $id module ID (case-sensitive) * @param string $id module ID (case-sensitive)
* @param boolean $loadIfNot whether to load the module if it is not yet. * @param boolean $load whether to load the module if it is not yet loaded.
* @return Module|null the module instance, null if the module * @return Module|null the module instance, null if the module
* does not exist. * does not exist.
* @see hasModule() * @see hasModule()
*/ */
public function getModule($id, $loadIfNot = true) public function getModule($id, $load = true)
{ {
if (isset($this->_modules[$id])) { if (isset($this->_modules[$id])) {
if ($this->_modules[$id] instanceof Module) { if ($this->_modules[$id] instanceof Module) {
return $this->_modules[$id]; return $this->_modules[$id];
} elseif ($loadIfNot) { } elseif ($load) {
\Yii::trace("Loading \"$id\" module", __CLASS__); \Yii::trace("Loading \"$id\" module", __CLASS__);
return $this->_modules[$id] = \Yii::createObject($this->_modules[$id], $id, $this); return $this->_modules[$id] = \Yii::createObject($this->_modules[$id], $id, $this);
} }
@ -308,17 +308,17 @@ abstract class Module extends Component implements Initable
/** /**
* Retrieves the named application component. * Retrieves the named application component.
* @param string $id application component ID (case-sensitive) * @param string $id application component ID (case-sensitive)
* @param boolean $loadIfNot whether to load the component if it is not yet. * @param boolean $load whether to load the component if it is not yet loaded.
* @return ApplicationComponent|null the application component instance, null if the application component * @return ApplicationComponent|null the application component instance, null if the application component
* does not exist. * does not exist.
* @see hasComponent() * @see hasComponent()
*/ */
public function getComponent($id, $loadIfNot = true) public function getComponent($id, $load = true)
{ {
if (isset($this->_components[$id])) { if (isset($this->_components[$id])) {
if ($this->_components[$id] instanceof ApplicationComponent) { if ($this->_components[$id] instanceof ApplicationComponent) {
return $this->_components[$id]; return $this->_components[$id];
} elseif ($loadIfNot) { } elseif ($load) {
\Yii::trace("Loading \"$id\" application component", __CLASS__); \Yii::trace("Loading \"$id\" application component", __CLASS__);
return $this->_components[$id] = \Yii::createObject($this->_components[$id]); return $this->_components[$id] = \Yii::createObject($this->_components[$id]);
} }

Loading…
Cancel
Save