Example #1
0
 /**
  * Gets a service call
  *
  * @param string    $id
  * @param ehough_iconic_Reference $reference
  *
  * @return string
  */
 private function getServiceCall($id, ehough_iconic_Reference $reference = null)
 {
     if ('service_container' === $id) {
         return '$this';
     }
     if (null !== $reference && ehough_iconic_ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
         return sprintf('$this->get(\'%s\', ehough_iconic_ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
     } else {
         if ($this->container->hasAlias($id)) {
             $id = (string) $this->container->getAlias($id);
         }
         return sprintf('$this->get(\'%s\')', $id);
     }
 }
 /**
  * Gets the service call.
  *
  * @param string    $id
  * @param ehough_iconic_Reference $reference
  *
  * @return string
  */
 private function getServiceCall($id, ehough_iconic_Reference $reference = null)
 {
     if (null !== $reference && ehough_iconic_ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
         return sprintf('@?%s', $id);
     }
     return sprintf('@%s', $id);
 }
 /**
  * Validates the scope of a single ehough_iconic_Reference.
  *
  * @param ehough_iconic_Reference  $reference
  * @param ehough_iconic_Definition $definition
  *
  * @throws ehough_iconic_exception_ScopeWideningInjectionException when the definition references a service of a narrower scope
  * @throws ehough_iconic_exception_ScopeCrossingInjectionException when the definition references a service of another scope hierarchy
  */
 private function validateScope(ehough_iconic_Reference $reference, ehough_iconic_Definition $definition = null)
 {
     if (ehough_iconic_ContainerInterface::SCOPE_PROTOTYPE === $this->currentScope) {
         return;
     }
     if (!$reference->isStrict()) {
         return;
     }
     if (null === $definition) {
         return;
     }
     if ($this->currentScope === ($scope = $definition->getScope())) {
         return;
     }
     $id = (string) $reference;
     if (in_array($scope, $this->currentScopeChildren, true)) {
         throw new ehough_iconic_exception_ScopeWideningInjectionException($this->currentId, $this->currentScope, $id, $scope);
     }
     if (!in_array($scope, $this->currentScopeAncestors, true)) {
         throw new ehough_iconic_exception_ScopeCrossingInjectionException($this->currentId, $this->currentScope, $id, $scope);
     }
 }