Component factory. Delegates the creation of components to a createComponent<Name> method.

@param string $name
137
protected function createComponent($name): ?IComponent
    {
        $method = 'createComponent'.ucfirst($name);
        if (method_exists($this, $method)) {
            $this->checkRequirements(self::getReflection()->getMethod($method));
        }

        return parent::createComponent($name);
    }
708698
public function publish($name)
    {
        if ($name instanceof Component) {
            $component = $name;
        } else {
            $component = $this->laravel['components']->findOrFail($name);
        }

        with(new AssetPublisher($component))
            ->setRepository($this->laravel['components'])
            ->setConsole($this)
            ->publish();

        $this->line("<info>Published</info>: {$component->getStudlyName()}");
    }
348645
public static function create($name) {
    if (is_string($name)) {
      $name = NameNode::create($name);
    }
    /** @var ConstantNode $node */
    $node = new static();
    $node->addChild($name, 'constantName');
    return $node;
  }
1255886
public function findOrFail($name)
    {
        $component = $this->find($name);

        if ($component !== null) {
            return $component;
        }

        throw new ComponentNotFoundException("Component [{$name}] does not exist!");
    }
136911
protected function setComponent($name, $value)
    {
        if ($this->_string !== null) {
            $this->_components = $this->parseUri($this->_string);
        }
        $this->_components[$name] = $value;
        $this->_string = null;
    }
1125084
protected function loadComponent($bindings, $name)
    {
        $aliases = array_values($bindings);
        $abstracts = array_keys($bindings);
        
        foreach ($abstracts as $index => $abstract) {
            $this->app->singleton(
                $abstract,
                $this->{"load{$name}Component"}()
            );
            
            $this->app->alias(
                $abstract,
                $aliases[$index]
            );
        }
    }
52262
public function callComponent($componentName)
    {
        if (!isset($this->components[$componentName])) {
            $requiredInterface = isset(static::$defaultComponents[$componentName][1])
                ? static::$defaultComponents[$componentName][1]
                : null;
            $componentConfig = isset(static::$defaultComponents[$componentName][2])
                ? static::$defaultComponents[$componentName][2]
                : [];
            if (isset($this->config['components'][$componentName])){
                $componentConfig = array_merge($componentConfig, $this->config['components'][$componentName]);
            }
            if (isset($componentConfig['class'])) {
                $componentClassName = $componentConfig['class'];
            } else {
                $componentClassName = isset(static::$defaultComponents[$componentName][0])
                    ? static::$defaultComponents[$componentName][0]
                    : null;
            }
            unset($this->config['components'][$componentName]);
            if (isset($componentConfig['class']))
            unset($componentConfig['class']);
            if ($componentClassName) {
                $instance = new $componentClassName($componentConfig, $this);
                if (null === $requiredInterface || ($instance instanceof $requiredInterface)) {
                    $this->components[$componentName] = $instance;
                } else {
                    throw new InvalidInterfaceException([$componentName, $componentClassName, $requiredInterface]);
                }
            } else {
                throw new UnknownComponentException($componentName);
            }
        }
        return $this->components[$componentName];
    }
1281084
public function actionComponent($name = null)
    {
        $data = Yii::$app->getComponents();
        if ($name) {
            if (empty($data[$name])) {
                Yii::error("'$name' not defined");

                return;
            }
            $data = [$name => $data[$name]];
        }
        echo Yaml::dump($data, 4);
    }
598181
protected function prepareFactory()
    {
        if (empty($this->componentFactory) && isset($this->configuration)) {
            $this->componentFactory = new ComponentFactory($this->configuration);
        }
    }
1189822
public function getComponent($name)
    {
        if (!isset($this->componentCache[$name]) && ($this->componentCache[$name]
            = $this->createComponent($name)) !== null) {
            $this->componentCache[$name]->init();
        }

        return $this->componentCache[$name];
    }
858089
function createComponent( &$xcaldecl ) {
    $objectname    = $this->_createFormat();
    $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
    $component    .= $this->createUid();
    $component    .= $this->createDtstamp();
    $component    .= $this->createAttach();
    $component    .= $this->createAttendee();
    $component    .= $this->createCategories();
    $component    .= $this->createClass();
    $component    .= $this->createComment();
    $component    .= $this->createCompleted();
    $component    .= $this->createContact();
    $component    .= $this->createCreated();
    $component    .= $this->createDescription();
    $component    .= $this->createDtstart();
    $component    .= $this->createDue();
    $component    .= $this->createDuration();
    $component    .= $this->createExdate();
    $component    .= $this->createExrule();
    $component    .= $this->createGeo();
    $component    .= $this->createLastModified();
    $component    .= $this->createLocation();
    $component    .= $this->createOrganizer();
    $component    .= $this->createPercentComplete();
    $component    .= $this->createPriority();
    $component    .= $this->createRdate();
    $component    .= $this->createRelatedTo();
    $component    .= $this->createRequestStatus();
    $component    .= $this->createRecurrenceid();
    $component    .= $this->createResources();
    $component    .= $this->createRrule();
    $component    .= $this->createSequence();
    $component    .= $this->createStatus();
    $component    .= $this->createSummary();
    $component    .= $this->createUrl();
    $component    .= $this->createXprop();
    if( $this->nl != substr( $component, ( 0 - strlen( $this->nl ))))
      $component  .= $this->nl;
    $component    .= $this->createSubComponent();
    $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
    if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
      foreach( $this->xcaldecl as $localxcaldecl )
        $xcaldecl[] = $localxcaldecl;
    }
    return $component;
  }
1329843
public function create($name)
    {
        $name = $this->resolveName($name);

        $prototype = $this->getPrototype($name);
        $product = $prototype->copy();        
        
        foreach($this->invocationsMethodsOnCreate[$name] as $methodName => $argTag)
        {
            if(isset($this->invokeArgs[$argTag]))
            {
                $arg = $this->invokeArgs[$argTag];
                $product->$methodName($arg);
            }
        }

        return $product;
    }
119128
public function isComponentVerified(string $name, Request $request, Component $parent): bool
    {
        $reflection = new ComponentReflection($parent);
        $method = 'createComponent'.ucfirst($name);
        if ($reflection->hasMethod($method)) {
            $factory = $reflection->getMethod($method);
            try {
                $this->checkReflection($factory, $request, $parent->getParent() !== null ? $parent->getUniqueId() : null);
            } catch (VerificationException $e) {
                return false;
            }
        }

        return true;
    }
310016
public function deleteComponentEntry($name)
	{
		if ($this->baseDb->tableExists('#__components'))
		{
			// Delete component entry
			$query = "DELETE FROM `#__components` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			$this->log(sprintf('Removed component entry for "%s"', $element));

			return true;
		}
		elseif ($this->baseDb->tableExists('#__extensions'))
		{
			$name = 'com_' . strtolower($name);
			// Delete component entry
			$query = "DELETE FROM `#__extensions` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			// Remove the component container in the assets table
			$asset = \Hubzero\Access\Asset::oneByName($name);
			if ($asset && $asset->get('id'))
			{
				$asset->destroy();
			}

			$this->log(sprintf('Removed extension entry for component "%s"', $element));

			if ($this->baseDb->tableExists('#__menu'))
			{
				// Check for an admin menu entry...if it's not there, create it
				$query = "DELETE FROM `#__menu` WHERE `menutype` = 'main' AND `title` = " . $this->baseDb->quote($name);
				$this->baseDb->setQuery($query);
				$this->baseDb->query();

				// Rebuild lft/rgt
				$this->rebuildMenu();

				$this->log(sprintf('Removed menu entry for component "%s"', $element));
			}

			return true;
		}

		return false;
	}
407077
private function processCreateDI($name)
    {
        $this->dependencyService->processCommand('injectModel', $name);
        $this->dependencyService->create($name);
    }
579158
public function get_by_name( $name )
    {
        $filtered = $this->filter(function($c) use ($name) {
            return $c instanceof ValueComponentInterface && $c->name === $name;
        });
        if(count($filtered) < 1)
        {
            throw new \RuntimeException("No component with the name <b>$name</b> could be found.");
        }
        return $filtered[0];
    }
76517
protected function createComponentForm(string $name): Form
    {
        $form = new Form($this, $name);
        $form->setTranslator($this->translator);
        $this->formContainer->getForm($form);

        $form->onSuccess[] = $this->eventContainer;
        return $form;
    }