Example #1
0
 /**
  * Get the existing factory for a class. If a factory is not already defined
  * a default one will be created via reflection.
  *
  * @param  string $class  Name of the class
  * @param  array  $params Optional
  *
  * @return FactoryInterface
  */
 public function getFactory($class, array $params = array())
 {
     if (!isset($this->factories[$class]) && $this->autowire) {
         $this->factories[$class] = Definition::getDefaultForClass($class);
     }
     $factory = $this->factories[$class];
     // if $params is defined, we need to either make a copy of the existing
     // Factory or make the Definition create a new factory with the params
     if ($params) {
         $factory = $factory->getFactory($params);
     }
     return $factory;
 }