예제 #1
0
 /**
  * @param string $name
  * @param bool $need
  * @return IComponent|null
  * @throws Mesour\InvalidStateException
  */
 public function getComponent($name, $need = true)
 {
     Mesour\Components\Utils\Helpers::validateComponentName($name);
     if (!isset($this->components[$name])) {
         if ($need) {
             throw new Mesour\InvalidStateException(sprintf('Component with name %s does not exists.', $name));
         }
         return null;
     }
     return $this->components[$name];
 }
예제 #2
0
 /**
  * @param string $name
  * @return $this
  */
 public function setName($name)
 {
     Mesour\Components\Utils\Helpers::validateComponentName($name);
     $this->name = $name;
     return $this;
 }