Return the many-to-many extra fields specification for a specific component.

@param string $class
@param string $component

@return array|null
511332
public function manyManyExtraFieldsForComponent($class, $component)
    {
        // Get directly declared many_many_extraFields
        $extraFields = Config::inst()->get($class, 'many_many_extraFields');
        if (isset($extraFields[$component])) {
            return $extraFields[$component];
        }

        // If not belongs_many_many then there are no components
        while ($class && ($class !== DataObject::class)) {
            $belongsManyMany = Config::inst()->get($class, 'belongs_many_many', Config::UNINHERITED);
            if (isset($belongsManyMany[$component])) {
                // Reverse relationship and find extrafields from child class
                $belongs = $this->parseBelongsManyManyComponent(
                    $class,
                    $component,
                    $belongsManyMany[$component]
                );
                return $this->manyManyExtraFieldsForComponent($belongs['childClass'], $belongs['relationName']);
            }
            $class = get_parent_class($class);
        }
        return null;
    }
382612
private function getClassConsts($class)
    {
        $result = '';
        foreach($class->getConstants() as $name => $value)
        {
            $value = var_export($value, true);
            $result .= <<<CODE

    const {$name} = $value;

CODE;
        }
        return $result;
    }
514267
public function getIdentifiers($class)
    {
        $schema = $this->getSchema($class);

        if (isset($schema->claroline)) {
            return $schema->claroline->ids;
        }

        return [];
    }
744079
private static function getProperties($class): array
    {
        $reflect = new \ReflectionClass($class);
        $prop = $reflect->getProperties(
            \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE
        );
        $properties = [];
        foreach ($prop as $property) {
            $properties[] = $property->name;
        }
        $parent = \get_parent_class($class);
        if ($parent) {
            $properties = \array_merge(self::getProperties($parent), $properties);
        }
        return $properties;
    }
110863
public static function getExtends($objectOrClass): array
    {
        if (is_object($objectOrClass)) {
            $objectOrClass = get_class($objectOrClass);
        }
        return array_values(class_parents($objectOrClass));
    }
1047760
protected function classUsesDeep($class)
    {
        $traits = [];

        // Get traits of all parent classes
        do {
            $traits = array_merge(class_uses($class), $traits);
        } while ($class = get_parent_class($class));

        // Get traits of all parent traits
        $traitsToSearch = $traits;
        while ( ! empty($traitsToSearch)) {
            $newTraits      = class_uses(array_pop($traitsToSearch));
            $traits         = array_merge($newTraits, $traits);
            $traitsToSearch = array_merge($newTraits, $traitsToSearch);
        };

        foreach ($traits as $trait => $same) {
            $traits = array_merge(class_uses($trait), $traits);
        }

        return array_unique($traits);
    }
289900
public static function getComponentPropertyValues($component)
    {
        $result = [];

        $result['oc.alias'] = $component->alias;

        $properties = $component->defineProperties();
        foreach ($properties as $name => $params) {
            $result[$name] = $component->property($name);
        }

        return json_encode($result);
    }
133022
protected function fetchTraits(string $class): array
    {
        $traits = [];

        while ($class) {
            $traits = array_merge(class_uses($class), $traits);
            $class = get_parent_class($class);
        }

        //Traits from traits
        foreach (array_flip($traits) as $trait) {
            $traits = array_merge(class_uses($trait), $traits);
        }

        return array_unique($traits);
    }
580606
public function getExtendedClass($class)
    {
        $ret = null;
        if (array_key_exists($class, $this->dynamicClasses)) {
            $ret = $this->dynamicClasses[$class];
        }
        if (!$ret) {
            $ret = array_search($class, $this->classes);
        }
        return $ret?$ret:null;
    }
308617
protected function getClassProviders(\ReflectionClass $class) {
		$annotations = Omocha::getAnnotations($class);
		
		//get class providers
		$providers = $annotations->find('Provider', Filter::TYPE_STRING);
		
		if (!empty($providers)) {
			$classes = [];
			
			foreach ($providers as $provider) {
				$classes[] = $provider->getValue();
			}
			
			return $classes;
		}
		
		//if no providers are specified try getting them from parent class
		if ($annotations->has('ExtendInject')) {
			$extend = $annotations->get('ExtendInject')->getValue();
			
			if ($extend) {
				$parent = $class->getParentClass();
				return $parent instanceof \ReflectionClass ? $this->getClassProviders($parent) : [];
			}
		}
		
		return [];
	}
607220
public static function getChildComponentClasses($class, $select = array())
    {
        $selectType = gettype($select);
        if ($selectType == 'string' && is_string($class)) {
            //simple case no. 1: get from specific generator
            $g = Kwc_Abstract::getSetting($class, 'generators');
            if (!isset($g[$select])) return array();
            return $g[$select]['component'];
        } else if (!$select && is_string($class)) {
            //simple case no. 2: get 'em all
            $ret = array();
            foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) {
                $ret = array_merge($ret, array_values($g['component']));
            }
            return array_unique($ret);

        } else if ($selectType == 'array' && is_string($class) && count($select) == 1 &&
            isset($select['componentClass']) && is_string($select['componentClass'])
        ) {
            //simple case no 3: looking for a single comopnentClass
            foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) {
                foreach ($g['component'] as $c) {
                    if ($c == $select['componentClass']) return array($c);
                }
            }
            return array();
        } else if ($selectType == 'array' && is_string($class) && count($select) == 1 &&
            isset($select['generatorFlags']) && $select['generatorFlags'] == array('static'=>true)
        ) {
            //simple case no 4: looking for a generator by flag
            $ret = array();
            foreach (Kwc_Abstract::getSetting($class, 'generators') as $key=>$gSettings) {
                $g = Kwf_Component_Generator_Abstract::getInstance($class, $key, $gSettings);
                if ($g->getGeneratorFlag('static')) {
                    foreach ($gSettings['component'] as $c) {
                        $ret[] = $c;
                    }
                }
            }
            return array_unique($ret);
        } else if ($selectType == 'array' && is_string($class) && count($select) == 2 &&
            isset($select['generator']) && isset($select['componentKey'])
        ) {
            //simple case no 5: looking for a generator plus componentKey
            $ret = array();
            $generators = Kwc_Abstract::getSetting($class, 'generators');
            if (isset($generators[$select['generator']]['component'][$select['componentKey']])) {
                $ret[] = $generators[$select['generator']]['component'][$select['componentKey']];
            }
            return $ret;

        } else if ($selectType == 'array') {
            $select = new Kwf_Component_Select($select);
        }
        //not so simple, else we ask Generator_Abstract::getInstances for help
        $ret = array();
        $generators = Kwf_Component_Generator_Abstract::getInstances($class, $select);
        if (!$generators) {
            return $ret;
        }
        foreach ($generators as $generator) {
            $c = $generator->getChildComponentClasses($select);
            if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) {
                $c = array_values($c);
            }
            $ret = array_merge($ret, $c);
        }
        if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) {
            $ret = array_unique($ret);
        }
        return $ret;
    }
33964
public static function get_extra_config($class, $extension, $args)
    {
        if (!self::is_translatable_installed()) {
            // remain silent during a test
            if (SapphireTest::is_running_test()) {
                return null;
            }
            // raise an error otherwise
            user_error('Translatable module is not installed but required.', E_USER_WARNING);
            return null;
        }

        if ($args) {
            self::$arguments[$class] = $args;
        }

        return array(
            'db' => self::collectDBFields($class),
            'has_one' => self::collectHasOneRelations($class)
        );
    }
1042543
public function getComponentByClass($class, $select = array())
    {
        $components = $this->getComponentsByClass($class, $select);
        $this->_checkSingleComponent($components);
        if (isset($components[0])) {
            return $components[0];
        }
        return null;
    }
714650
protected function getDependencies($class)
    {
        if (isset($this->_reflections[$class])) {
            return [$this->_reflections[$class], $this->_dependencies[$class]];
        }

        $dependencies = [];
        $reflection = new ReflectionClass($class);

        $constructor = $reflection->getConstructor();
        if ($constructor !== null) {
            foreach ($constructor->getParameters() as $param) {
                if ($param->isDefaultValueAvailable()) {
                    $dependencies[] = $param->getDefaultValue();
                } else {
                    $c = $param->getClass();
                    $dependencies[] = Instance::of($c === null ? null : $c->getName());
                }
            }
        }

        $this->_reflections[$class] = $reflection;
        $this->_dependencies[$class] = $dependencies;

        return [$reflection, $dependencies];
    }
730040
protected function findModuleForClass($class)
    {
        if (ClassInfo::exists($class)) {
            $module = ClassLoader::inst()
                ->getManifest()
                ->getOwnerModule($class);
            if ($module) {
                return $module->getName();
            }
        }

        // If we can't find a class, see if it needs to be fully qualified
        if (strpos($class, '\\') !== false) {
            return null;
        }

        // Find FQN that ends with $class
        $classes = preg_grep(
            '/' . preg_quote("\\{$class}", '\/') . '$/i',
            ClassLoader::inst()->getManifest()->getClassNames()
        );

        // Find all modules for candidate classes
        $modules = array_unique(array_map(function ($class) {
            $module = ClassLoader::inst()->getManifest()->getOwnerModule($class);
            return $module ? $module->getName() : null;
        }, $classes));

        if (count($modules) === 1) {
            return reset($modules);
        }

        // Couldn't find it! Exists in none, or multiple modules.
        return null;
    }
310856
public function find($class)
    {
        $reflectionClass = new \ReflectionClass($class);

        do {
            $classNamespace = $reflectionClass->getNamespaceName();
            foreach ($this->bundles as $bundleName => $bundleClass) {
                $bundleNamespace = \substr($bundleClass, 0, \strrpos($bundleClass, '\\'));
                if (0 === \strpos($classNamespace, $bundleNamespace)) {
                    return $bundleName;
                }
            }
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);

        return null;
    }
311891
public static function get_localized_class_fields($class)
    {
        $fieldNames = null;
        $ancestry = array_reverse(ClassInfo::ancestry($class));
        foreach ($ancestry as $className) {
            if (isset(self::$localizedFields[$className])) {
                if ($fieldNames === null) {
                    $fieldNames = array();
                }
                foreach (self::$localizedFields[$className] as $k => $v) {
                    $fieldNames[] = $k;
                }
            }
        }
        return array_unique($fieldNames);
    }