예제 #1
0
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $factory = new Factory();
     $this->fixtureProvider = new FixtureProvider($this, $factory);
     $factory->setProvider(Fixture::$CLASS, $this->fixtureProvider);
     $injector = new Injector($factory);
     $injector->injectPropertyAnnotations($this, array($this, 'annotationPropertyFilter'));
     $this->setTimeZone();
 }
예제 #2
0
파일: ObjectField.php 프로젝트: rtens/domin
 private function createInstance(Parameter $parameter, $properties)
 {
     $injector = new Injector(new Factory());
     $instance = $injector->injectConstructor($this->getClass($parameter), $properties, function () {
         return false;
     });
     foreach ($this->getProperties($parameter) as $property) {
         $property->set($instance, $properties[$property->name()]);
     }
     return $instance;
 }
예제 #3
0
 /**
  * @param Console $console
  * @param array $arguments Arguments as produced by the Parser
  * @throws \Exception If the class does not implement a "doExecute" method
  * @return void
  */
 public function execute(Console $console, array $arguments)
 {
     $injector = new Injector($this->factory);
     $methodName = $this->getExecutionMethodName();
     try {
         $method = new \ReflectionMethod($this, $methodName);
     } catch (\ReflectionException $e) {
         throw new \Exception("Command [" . get_class($this) . "] must implement the method [{$methodName}].");
     }
     $this->factory->setSingleton($console, Console::$CLASS);
     $resolved = $this->resolveFlags($method, $arguments);
     $filtered = $this->filter($method, $resolved);
     $arguments = $injector->injectMethodArguments($method, $filtered, $this->parameterInjectionFilter);
     $this->checkArguments($method, $resolved);
     $method->invokeArgs($this, $arguments);
 }
예제 #4
0
파일: ObjectField.php 프로젝트: rtens/domin
 /**
  * @param Parameter $parameter
  * @param null $serialized
  * @return object
  */
 public function inflate(Parameter $parameter, $serialized)
 {
     $properties = [];
     foreach ($this->getProperties($parameter) as $property) {
         $propertyParameter = new Parameter($parameter->getName() . '-' . $property->name(), $property->type());
         $field = $this->getField($propertyParameter);
         $properties[$property->name()] = $field->inflate($propertyParameter, $this->reader->read($propertyParameter));
     }
     $injector = new Injector(new Factory());
     $instance = $injector->injectConstructor($this->getClass($parameter), $properties, function () {
         return false;
     });
     foreach ($this->getProperties($parameter) as $property) {
         $value = $properties[$property->name()];
         if (!is_null($value) && $property->canSet()) {
             $property->set($instance, $value);
         }
     }
     return $instance;
 }
예제 #5
0
파일: ObjectField.php 프로젝트: jonfm/domin
 /**
  * @param Parameter $parameter
  * @param \watoki\collections\Map $serialized
  * @return object
  */
 public function inflate(Parameter $parameter, $serialized)
 {
     $reader = new PropertyReader($this->types, $this->getClass($parameter));
     $properties = [];
     foreach ($reader->readInterface() as $property) {
         if ($serialized->has($property->name())) {
             $param = $this->makePropertyParameter($parameter, $property);
             $properties[$property->name()] = $this->getField($param)->inflate($param, $serialized[$property->name()]);
         }
     }
     $injector = new Injector(new Factory());
     $instance = $injector->injectConstructor($this->getClass($parameter), $properties, function () {
         return false;
     });
     foreach ($reader->readInterface() as $property) {
         if ($property->canSet()) {
             $property->set($instance, $properties[$property->name()]);
         }
     }
     return $instance;
 }
예제 #6
0
 protected function createInstance(array $parameters)
 {
     $injector = new Injector(new Factory());
     $instance = $injector->injectConstructor($this->class->name, $parameters, function () {
         return false;
     });
     foreach ($this->reader->readInterface() as $property) {
         if ($property->canSet() && array_key_exists($property->name(), $parameters)) {
             $property->set($instance, $parameters[$property->name()]);
         }
     }
     return $instance;
 }