批量设置 component 属性
@param array $components
358655
public function setComponents(array $components)
    {
        foreach ($components as $id => $properties) {
            $this->setComponent($id, $properties);
        }
    }
495223
public function generate(array $components)
    {
        $uri = $components['scheme'] . '://'
             . $components['authority']
             . $components['path'];

        if (array_key_exists('query', $components) && strlen($components['query'])) {
            $uri .= '?' . $components['query'];
        }
        if (array_key_exists('fragment', $components)) {
            $uri .= '#' . $components['fragment'];
        }

        return $uri;
    }
1346507
private function constructString(array $components)
    {
        $formats = array_keys($components);
        $values = array_values($components);
        $keys = array_keys(array_filter($values, 'strlen'));

        return array_reduce($keys, function ($string, $key) use ($formats, $values) {
            return sprintf($formats[$key], $string, $values[$key]);
        }, '');
    }
233115
public function delete_component_files($component) {
        global $DB;

        $filerecords = $DB->get_recordset('files', array('component' => $component));
        foreach ($filerecords as $filerecord) {
            $this->get_file_instance($filerecord)->delete();
        }
        $filerecords->close();
    }
959660
private function loadComponents()
    {
        if (!$this->componentsloaded) {
            foreach ($this->getSettings()->getComponents() as $componentClass) {
                $component = new $componentClass();
                if ($component instanceof ComponentInterface) {
                    $this->addComponent($component);
                }
            }
            $this->componentsloaded = true;
        }
    }
790413
private static function _parseTemplates(array &$components, $path)
    {
        if (!file_exists($path)) {
            return;
        }
        foreach (new \DirectoryIterator($path) as $template) {
            if ($template->isDot()) {
                continue;
            }
            if ($template->isFile()) {
                $components[substr($template->getFilename(), 0, -4)] = $template->getPathname();
                continue;
            }
            if ($template->isDir()) {
                $components[$template->getFilename()] = [];
                self::_parseTemplates($components[$template->getFilename()], $template->getPathname());
            }
        }
    }
1245502
public function setComponents($components)
  {
    if (ThrottlerHelper::validateComponents($components)
        && !$this->isActive())
    {
      $this->components = $components;
      return true;
    }
    return false;
  }
1121556
public function getComponents($component = null)
    {
        if (is_null($component)) {
            return $this->components;
        }

        $this->validateComponentExists($component);

        return $this->components[$component];
    }
1372334
public static function get($name)
    {
        if ( ! isset(self::$components[$name]))
        {
            // 检查配置表是否有记录
            if ( ! $config = Config::load('main')->get('component.' . $name))
            {
                throw new ComponentNotFoundException('The requested component [:component] not found.', [
                    ':component' => $name,
                ]);
            }
            self::set($name, $config);
        }

        return self::$components[$name];
    }
724875
public function setComponent($id, $properties)
    {
        if (null === $properties) {
            unset($this->_components[$id]);
        } elseif (isset($this->_components[$id])) {
            $component = $this->_components[$id];
            /* @var Component $component */
            $component->configure($properties);
            $this->_componentConfig[$id] = array_merge($this->_componentConfig[$id], $properties);
        } elseif (isset($this->_componentConfig[$id])) {
            $this->_componentConfig[$id] = array_merge($this->_componentConfig[$id], $properties);
        } else {
            $this->_componentConfig[$id] = $properties;
        }
    }
807538
public function setComponents($components)
    {
        $this->components = Collection::make($components);
        foreach ($components as $component) {
            $component->attachTo($this);
        }
        return $this;
    }
663117
private function describeComponents($components, $name, OutputInterface $output, $depth = 0)
    {
        if (is_array($components)) {
            $output->writeln(sprintf('%s<comment>%s</comment>', str_repeat(' ', $depth), $name));

            foreach ($components as $component) {
                $output->writeln(sprintf(
                    '%s%s',
                    str_repeat(' ', $depth + 4),
                    is_object($component) ? get_class($component) : get_class($component[0])
                ));
            }
        }
    }
610339
private function _parseComponent($components)
    {

        $address = new GeoAddress();
        $address->geoCoding = $this->name;
        $streetNumber = '';
        $routeName = '';

        foreach ($components as $component) {
            if (isset($component['types'])) {
                if (in_array('street_number', $component['types'])) {
                    $streetNumber = $component['short_name'];
                }

                if (in_array('route', $component['types'])) {
                    $routeName = $component['short_name'];
                }

                if (in_array('administrative_area_level_1', $component['types'])) {
                    $address->state = $component['short_name'];
                }

                if (in_array('locality', $component['types'])) {
                    $address->suburb = $component['short_name'];
                }

                if (in_array('postal_code', $component['types'])) {
                    $address->postcode = $component['short_name'];
                }

                if (in_array('country', $component['types'])) {
                    $address->country = $component['long_name'];
                }
            }

        }



        if ($routeName || $streetNumber) {
            $address->addressLine1 = trim($streetNumber . ' ' . $routeName);
        }



        return $address;
    }
879076
public function options( $component, $options ) {

		if ( ! isset( $this->settings['components'][ $component ] ) || ! is_array( $this->settings['components'][ $component ] ) ) {
			$this->settings['components'][ $component ] = array();
		}

		foreach ( $options as $option => $data ) {
			if ( ! isset( $this->settings['components'][ $component ][ $option ] ) && isset( $data['default'] ) ) {
				$this->settings['components'][ $component ][ $option ] = $data['default'];
			}
		}
	}
1307459
public function pushTrail($components)
    {
        $trail = &$this->getTrail();

        if ($components instanceof QtiComponent) {
            array_push($trail, $components);
        } else {
            $i = count($components);
            // collection
            while ($i >= 1) {
                $i--;
                array_push($trail, $components[$i]);
            }
        }
    }
965136
public function performPost(array $components)
    {
        $response = $this->httpClient->post('', [
            'json' => ['components' => $components]
        ]);

        return (string) $response->getBody();
    }
1714
protected function guessBestComponent(array $components, array $keys)
    {
        foreach ($keys as $key) {
            if (isset($components[$key]) && !empty($components[$key])) {
                return $components[$key];
            }
        }

        return null;
    }