Example #1
0
 /**
  * Collect parent types configuration for requested type
  *
  * @param string $type
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _collectConfiguration($type)
 {
     if (!isset($this->_mergedArguments[$type])) {
         if (isset($this->_virtualTypes[$type])) {
             $arguments = $this->_collectConfiguration($this->_virtualTypes[$type]);
         } else {
             if ($this->_relations->has($type)) {
                 $relations = $this->_relations->getParents($type);
                 $arguments = array();
                 foreach ($relations as $relation) {
                     if ($relation) {
                         $relationArguments = $this->_collectConfiguration($relation);
                         if ($relationArguments) {
                             $arguments = array_replace($arguments, $relationArguments);
                         }
                     }
                 }
             } else {
                 $arguments = array();
             }
         }
         if (isset($this->_arguments[$type])) {
             if ($arguments && count($arguments)) {
                 $arguments = array_replace_recursive($arguments, $this->_arguments[$type]);
             } else {
                 $arguments = $this->_arguments[$type];
             }
         }
         $this->_mergedArguments[$type] = $arguments;
         return $arguments;
     }
     return $this->_mergedArguments[$type];
 }
Example #2
0
 /**
  * Process interception inheritance
  *
  * @param string $type
  * @return bool
  */
 protected function _inheritInterception($type)
 {
     if (!isset($this->_intercepted[$type])) {
         $realType = $this->_omConfig->getOriginalInstanceType($type);
         if ($type !== $realType) {
             if ($this->_inheritInterception($realType)) {
                 $this->_intercepted[$type] = true;
                 return true;
             }
         } else {
             $parts = explode('\\', $type);
             if (!in_array(end($parts), $this->_serviceClassTypes) && $this->_relations->has($type)) {
                 $relations = $this->_relations->getParents($type);
                 foreach ($relations as $relation) {
                     if ($relation && $this->_inheritInterception($relation)) {
                         $this->_intercepted[$type] = true;
                         return true;
                     }
                 }
             }
         }
         $this->_intercepted[$type] = false;
     }
     return $this->_intercepted[$type];
 }
Example #3
0
 /**
  * Collect parent types configuration for requested type
  *
  * @param string $type
  * @return array
  * @throws InvalidArgumentException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _inheritPlugins($type)
 {
     if (!array_key_exists($type, $this->_inherited)) {
         $realType = $this->_omConfig->getOriginalInstanceType($type);
         if ($realType !== $type) {
             $plugins = $this->_inheritPlugins($realType);
         } else {
             if ($this->_relations->has($type)) {
                 $relations = $this->_relations->getParents($type);
                 $plugins = array();
                 foreach ($relations as $relation) {
                     if ($relation) {
                         $relationPlugins = $this->_inheritPlugins($relation);
                         if ($relationPlugins) {
                             $plugins = array_replace_recursive($plugins, $relationPlugins);
                         }
                     }
                 }
             } else {
                 $plugins = array();
             }
         }
         if (isset($this->_data[$type])) {
             if (!$plugins) {
                 $plugins = $this->_data[$type];
             } else {
                 $plugins = array_replace_recursive($plugins, $this->_data[$type]);
             }
         }
         $this->_inherited[$type] = null;
         if (is_array($plugins) && count($plugins)) {
             uasort($plugins, array($this, '_sort'));
             $this->_inherited[$type] = $plugins;
             $lastPerMethod = array();
             foreach ($plugins as $key => $plugin) {
                 // skip disabled plugins
                 if (isset($plugin['disabled']) && $plugin['disabled']) {
                     unset($plugins[$key]);
                     continue;
                 }
                 $pluginType = $this->_omConfig->getOriginalInstanceType($plugin['instance']);
                 if (!class_exists($pluginType)) {
                     throw new InvalidArgumentException('Plugin class ' . $pluginType . ' doesn\'t exist');
                 }
                 foreach ($this->_definitions->getMethodList($pluginType) as $pluginMethod => $methodTypes) {
                     $current = isset($lastPerMethod[$pluginMethod]) ? $lastPerMethod[$pluginMethod] : '__self';
                     $currentKey = $type . '_' . $pluginMethod . '_' . $current;
                     if ($methodTypes & Definition::LISTENER_AROUND) {
                         $this->_processed[$currentKey][Definition::LISTENER_AROUND] = $key;
                         $lastPerMethod[$pluginMethod] = $key;
                     }
                     if ($methodTypes & Definition::LISTENER_BEFORE) {
                         $this->_processed[$currentKey][Definition::LISTENER_BEFORE][] = $key;
                     }
                     if ($methodTypes & Definition::LISTENER_AFTER) {
                         $this->_processed[$currentKey][Definition::LISTENER_AFTER][] = $key;
                     }
                 }
             }
         }
         return $plugins;
     }
     return $this->_inherited[$type];
 }