Permalink
Browse files

fixed core components determination

  • Loading branch information...
1 parent 369993f commit 87770cf371ef54c8215c2488ed0b9d7721bc22ed anton committed Nov 6, 2012
Showing with 27 additions and 10 deletions.
  1. +22 −5 components/entity/AmEntity.php
  2. +4 −4 models/AmEntityCoreComponents.php
  3. +1 −1 models/AmEntityCoreModules.php
@@ -36,6 +36,10 @@ class AmEntity extends AmModel
*/
protected $name;
/**
+ * @var string
+ */
+ protected $defaultName;
+ /**
* @var string Yii alias to the entity class.
*/
protected $fullClassName;
@@ -271,11 +275,24 @@ public function setName($name)
*/
public function getDefaultName()
{
- $id = $this->getId();
- $tmp = explode('.', $id);
- $name = array_pop($tmp);
- $name[0] = strtolower($name[0]);
- return $name;
+ if (null === $this->defaultName) {
+ $id = $this->getId();
+ $tmp = explode('.', $id);
+ $name = array_pop($tmp);
+ $name[0] = strtolower($name[0]);
+ $this->defaultName = $name;
+ }
+ return $this->defaultName;
+ }
+
+ /**
+ * @param string $name
+ * @return AmEntity
+ */
+ public function setDefaultName($name)
+ {
+ $this->defaultName = $name;
+ return $this;
}
/**
@@ -4,11 +4,11 @@ class AmEntityCoreComponents extends AmEntityComponents
{
public function getChild($id)
{
- $components = $this->scan();
- if (false === array_search($id, $components)) {
+ $name = array_search($id, $this->scan());
+ if (false === $name) {
return null;
}
- return $this->createChild($id);
+ return $this->createChild($id, $name);
}
protected function scan()
@@ -45,7 +45,7 @@ protected function createChildren($results)
protected function createChild($id, $name = null)
{
$entity = parent::createChild($id);
- $entity->setName($name);
+ $entity->setDefaultName($name);
$entity->setFullClassName($this->getParent()->getId() . '.' . $id);
return $entity;
}
@@ -27,7 +27,7 @@ protected function createChildren($results)
protected function createChild($id, $name = null)
{
$entity = parent::createChild($id);
- $entity->setName($name);
+ $entity->setDefaultName($name);
$entity->setFullClassName($this->getParent()->getId() . '.' . $id);
return $entity;
}

0 comments on commit 87770cf

Please sign in to comment.