Xpressengine\Plugin\PluginEntity::getComponentList PHP Method

getComponentList() public method

플러그인이 소유한 컴포넌트 목록을 조회한다. type이 지정돼 있을 경우 해당 type의 컴포넌트를 조회한다.
public getComponentList ( string $type = null ) : array
$type string component type
return array
    public function getComponentList($type = null)
    {
        $componentList = $this->getMetaData('extra.xpressengine.component');
        if ($componentList === null) {
            $componentList = [];
        }
        if ($type === null) {
            return $componentList;
        } else {
            $componentsFetched = [];
            array_walk($componentList, function ($info, $key) use(&$componentsFetched, $type) {
                $componentType = $this->getComponentType($key);
                if ($componentType === $type) {
                    $componentsFetched[$key] = $info;
                }
            });
            return $componentsFetched;
        }
    }

Usage Example

 /**
  * 주어진 플러그인에 포함된 component를 register에 등록한다.
  *
  * @param PluginEntity $entity 플러그인
  *
  * @return void
  */
 public function addByEntity(PluginEntity $entity)
 {
     $componentList = $entity->getComponentList();
     foreach ($componentList as $id => $info) {
         $info['id'] = $id;
         $this->setComponentInfo($info);
         $this->add($info['class']);
     }
 }
All Usage Examples Of Xpressengine\Plugin\PluginEntity::getComponentList