Nette\DI\Config\Helpers::isInheriting PHP Method

isInheriting() public static method

public static isInheriting ( &$data ) : boolean
return boolean
    public static function isInheriting(&$data)
    {
        return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] !== self::OVERWRITE;
    }

Usage Example

コード例 #1
0
ファイル: Compiler.php プロジェクト: cujan/atlashornin
 /**
  * Parses section 'services' from (unexpanded) configuration file.
  * @return void
  */
 public static function parseServices(ContainerBuilder $builder, array $config, $namespace = NULL)
 {
     $services = isset($config['services']) ? $config['services'] : array();
     $factories = isset($config['factories']) ? $config['factories'] : array();
     $all = array_merge($services, $factories);
     uasort($all, function ($a, $b) {
         return strcmp(Config\Helpers::isInheriting($a), Config\Helpers::isInheriting($b));
     });
     if (!empty($config['factories'])) {
         trigger_error("Section 'factories' is deprecated, move definitions to section 'services' and append key 'autowired: no'.", E_USER_DEPRECATED);
     }
     foreach ($all as $origName => $def) {
         if ((string) (int) $origName === (string) $origName) {
             $name = count($builder->getDefinitions()) . preg_replace('#\\W+#', '_', $def instanceof \stdClass ? ".{$def->value}" : (is_scalar($def) ? ".{$def}" : ''));
         } elseif (array_key_exists($origName, $services) && array_key_exists($origName, $factories)) {
             throw new ServiceCreationException("It is not allowed to use services and factories with the same name: '{$origName}'.");
         } else {
             $name = ($namespace ? $namespace . '.' : '') . strtr($origName, '\\', '_');
         }
         $params = $builder->parameters;
         if (is_array($def) && isset($def['parameters'])) {
             foreach ((array) $def['parameters'] as $k => $v) {
                 $v = explode(' ', is_int($k) ? $v : $k);
                 $params[end($v)] = $builder::literal('$' . end($v));
             }
         }
         $def = Helpers::expand($def, $params);
         if (($parent = Config\Helpers::takeParent($def)) && $parent !== $name) {
             $builder->removeDefinition($name);
             $definition = $builder->addDefinition($name, $parent === Config\Helpers::OVERWRITE ? NULL : unserialize(serialize($builder->getDefinition($parent))));
         } elseif ($builder->hasDefinition($name)) {
             $definition = $builder->getDefinition($name);
         } else {
             $definition = $builder->addDefinition($name);
         }
         try {
             static::parseService($definition, $def);
         } catch (\Exception $e) {
             throw new ServiceCreationException("Service '{$name}': " . $e->getMessage(), NULL, $e);
         }
         if (array_key_exists($origName, $factories)) {
             $definition->setAutowired(FALSE);
         }
         if ($definition->class === 'self') {
             $definition->class = $origName;
             trigger_error("Replace service definition '{$origName}: self' with '- {$origName}'.", E_USER_DEPRECATED);
         }
         if ($definition->factory && $definition->factory->entity === 'self') {
             $definition->factory->entity = $origName;
             trigger_error("Replace service definition '{$origName}: self' with '- {$origName}'.", E_USER_DEPRECATED);
         }
     }
 }
All Usage Examples Of Nette\DI\Config\Helpers::isInheriting