Пример #1
0
 /**
  * Create (or get for Session / Singleton beanRepository) the instance of the bean
  *
  * @param BeanEnvelope $beanStructure
  *
  * @return Object
  *
  * @throws OvoContainerException
  */
 public function initializeBean(BeanEnvelope $beanStructure)
 {
     $this->logger->debug('Create Object from Core: ' . $beanStructure->getClass());
     $beanInstance = $this->getScopeObjectCreator($beanStructure->getScope())->createBean($beanStructure);
     if (!is_object($beanInstance)) {
         $this->logger->error('Error in the creation of the bean with name ' . $beanStructure->getName());
         throw new OvoContainerException('Error in bean creation ' . $beanStructure->getName());
     }
     return $beanInstance;
 }
Пример #2
0
 /**
  * Method to serialize all the objects handled by the session manager
  *
  * @return void
  */
 public function store()
 {
     $this->logger->debug('Save all beans of the session');
     foreach ($this->sessionObjectsRepository as $beanName => $beanInstance) {
         try {
             $_SESSION[$this->sessionName][$beanName] = serialize($beanInstance);
         } catch (\Exception $e) {
             if (is_object($beanInstance)) {
                 $this->logger->error('Error while serializing class ' . get_class($beanInstance) . ' for bean: ' . $beanName);
             }
             $this->logger->error($e->getMessage());
             throw new OvoContainerException($e->getMessage());
         }
     }
 }
Пример #3
0
 /**
  * Create the bean instance form the beanEnvelope
  *
  * @param BeanEnvelope $beanEnvelope
  *
  * @return Object
  *
  * @throws OvoContainerException
  */
 private function getBeanInstance(BeanEnvelope $beanEnvelope)
 {
     try {
         BeansRequestManager::add($beanEnvelope, $this->contextReferenceId);
         $beanInstance = $this->createInstance($beanEnvelope);
         BeansRequestManager::release($beanEnvelope, $this->contextReferenceId);
         return $beanInstance;
     } catch (OvoCircularDependencyException $e) {
         $this->logger->error('OvoCircularDependencyException exception: ' . $e->getMessage());
         $this->unsetCircularDependencisDetector();
         throw new OvoContainerException($e->getMessage());
     } catch (OvoInternalException $e) {
         $this->logger->error('OvoInternalException exception: ' . $e->getMessage());
         $this->destroyBean($e->getBeanStructure()->getName());
         BeansRequestManager::releaseAll($this->contextReferenceId);
         throw new OvoContainerException($e->getMessage());
     }
 }