Пример #1
0
 public function call($className, $methodName, array $arguments = [])
 {
     $class = $this->container->get($className);
     if (A7::methodExists($class, $methodName)) {
         $reflectorMethod = ReflectionUtils::getInstance()->getMethodReflection($className, $methodName);
         foreach ($reflectorMethod->getParameters() as $param) {
             if (isset($arguments[$param->name])) {
                 $paramRefClass = $param->getClass();
                 if ($paramRefClass instanceof \ReflectionClass) {
                     $parentClass = $paramRefClass->getParentClass();
                     if ($parentClass && $parentClass->name == 'MD\\Helpers\\Model') {
                         if (!$arguments[$param->name] instanceof Model) {
                             $arguments[$param->name] = new $paramRefClass->name($arguments[$param->name]);
                         }
                     } elseif ($paramRefClass->name == 'DateTime') {
                         if (!$arguments[$param->name] instanceof \DateTime) {
                             $arguments[$param->name] = new \DateTime($arguments[$param->name]);
                         }
                     }
                 }
             }
         }
     } else {
         throw new UndefinedMethodException();
     }
     return $this->container->call($class, $methodName, $arguments);
 }
Пример #2
0
 private function init()
 {
     if (!$this->isInit) {
         $this->isInit = true;
         $this->DBInstance = null;
         if (isset($this->parameters['instance']) && is_object($this->parameters['instance'])) {
             $this->DBInstance = $this->parameters['instance'];
         } elseif (isset($this->parameters['class'])) {
             $this->DBInstance = $this->a7->get($this->parameters['class']);
         }
         $this->beginTransaction = isset($this->parameters['beginTransaction']) ? $this->parameters['beginTransaction'] : 'beginTransaction';
         $this->commit = isset($this->parameters['commit']) ? $this->parameters['commit'] : 'commit';
         $this->rollback = isset($this->parameters['rollback']) ? $this->parameters['rollback'] : 'rollback';
     }
 }
Пример #3
0
 public function testGetWithNoneNamespace()
 {
     // Test data
     $className = 'EmptyClass6';
     $injectable = new Injectable();
     $injectable->lazy = false;
     // Expectations
     $this->annotationManager->expects($this->exactly(2))->method("getClassAnnotation")->with($className, "Injectable")->willReturn($injectable);
     $this->annotationManager->expects($this->once())->method("getMethodsAnnotations")->with($className)->willReturn([]);
     // Run Test
     $object = $this->a7->get($className);
     $this->assertInstanceOf($className, $object);
 }