Exemplo n.º 1
0
 /**
  * Get The Object (string, int, boolean or Object) of the dependency
  *
  * @param array $dependency the dependency description
  * @param string $contextReferenceId the context reference ID
  *
  * @return object the object to inject in the bean
  */
 private static function resolveTypeOfDependency($dependency, $contextReferenceId)
 {
     self::$logger->debug('Get Dependency type ' . $dependency['name']);
     $objectToInject = null;
     if (isset($dependency['ref'])) {
         //If the dependency is a object, I get this object from the container
         $objectToInject = SingletonCoreContainer::getInstance($contextReferenceId)->getBean($dependency['ref']);
     } else {
         //If not "object", check if is "array"
         $dependency = self::isArrayDependency($dependency);
         switch ($dependency['type']) {
             case ArgsValue::STRING:
                 $objectToInject = (string) $dependency['value'];
                 break;
             case ArgsValue::INT:
                 $objectToInject = (int) $dependency['value'];
                 break;
             case ArgsValue::BOOLEAN:
                 $objectToInject = (bool) $dependency['value'];
                 break;
             case ArgsValue::ARRAYLIST:
                 $objectToInject = (array) $dependency['value'];
                 break;
         }
     }
     return $objectToInject;
 }
Exemplo n.º 2
0
 /**
  * Get Bean construct values
  *
  * @param array $args bean's constructors args
  *
  * @return array array with the dependencies of the bean
  */
 private function argsControl($args, $contextReferenceId)
 {
     $this->logger->debug('Get Args value');
     $constructArgs = array();
     foreach ($args as $arg) {
         $arg = $this->isDependencyArray($arg);
         switch ($arg['type']) {
             case ArgsValue::BEAN:
                 $constructArgs[] = SingletonCoreContainer::getInstance($contextReferenceId)->getBean($arg['ref']);
                 break;
             case ArgsValue::INT:
                 $constructArgs[] = (int) $arg['name'];
                 break;
             case ArgsValue::STRING:
                 $constructArgs[] = (string) $arg['name'];
                 break;
             case ArgsValue::BOOLEAN:
                 $constructArgs[] = (bool) $arg['name'];
                 break;
             case ArgsValue::ARRAYLIST:
                 $constructArgs[] = (array) $arg['valueOf'];
                 break;
             default:
                 $constructArgs[] = $arg['name'];
                 break;
         }
     }
     return $constructArgs;
 }
Exemplo n.º 3
0
 /**
  * Get the ContextReader and set up this into the Container
  *
  * @param Configuration $configuration the Configuration implementation
  * @param string $contextReferenceId the context application reference id
  *
  * @return void
  */
 private function init(Configuration $configuration, $contextReferenceId)
 {
     $this->logger->debug('Create configuration ' . get_class($configuration));
     $contextReader = $configuration->getContextReader();
     $this->coreContainer = SingletonCoreContainer::getInstance($contextReferenceId);
     $this->isApplicationLoaded($contextReader, $contextReferenceId);
     if ($configuration->isLoadedForTheFirstTime() and PropertiesLoader::getProperty(self::LAZY_INIT) == 'false') {
         $this->initBeans($contextReader);
     }
 }