Get the latest version of each component.

@param string $componentId [optional] If set, only this component's data
will be returned.
@return string[]
320215
public function componentsVersion($componentId = null)
    {
        $components = $this->components ?: $this->loadComponents();

        array_walk($components, function (&$component) {
            $component = $component['version'];
        });

        return $componentId
            ? [$componentId => $components[$componentId]]
            : $components;
    }
1121556
public function getComponents($component = null)
    {
        if (is_null($component)) {
            return $this->components;
        }

        $this->validateComponentExists($component);

        return $this->components[$component];
    }
1175948
public function findByAttributes($componentId = null)
    {
        return $this->model->with('component', 'priority', 'user', 'brand')->whereHas('component', function($q) use($componentId) {
                    $q->where('active', 1);
                    if (!is_null($componentId)) {
                        $q->where('id', $componentId);
                    }
                })->where('brand_id', brand_id())->orderBy('created_at', 'desc');
    }
462814
private function getIncidents($componentId = null, $unresolvedOnly = true)
    {
        $incidents = [];
        if ($this->isConfigured()) {
            $clientIdKey = $this->getClientIdKey();
            $cacheKey    = 'statuspageIncidents'.$this->keys[$clientIdKey];
            $cacheExpire = 10;
            if (!$incidents = $this->cache->get($cacheKey, $cacheExpire)) {
                $clientSKey = $this->getClientSecretKey();
                $state      = $this->getAuthLoginState();
                $url        = $this->getAuthenticationUrl();
                if ($unresolvedOnly) {
                    $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents/unresolved.json';
                } else {
                    $url .= 'pages/'.$this->keys[$clientIdKey].'/incidents.json';
                }
                $url .= '?api_key='.$this->keys[$clientSKey]
                    .'&response_type=code'
                    .'&state='.$state;
                $incidents = $this->makeRequest($url, ['ignore_event_dispatch' => true]);
                if (is_array($incidents) && count($incidents)) {
                    $this->cache->set($cacheKey, $incidents, $cacheExpire);
                }
            }
        }
        // Narrow down to just the affected component if specified.
        if ($incidents && $componentId) {
            $affected = [];
            foreach ($incidents as $incident) {
                if (!empty($incident['incident_updates'])) {
                    foreach ($incident['incident_updates'] as $update) {
                        if (!empty($update['affected_components'])) {
                            foreach ($update['affected_components'] as $component) {
                                if (!empty($component['code']) && $component['code'] === $componentId) {
                                    $affected[] = $incident;
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
            $incidents = $affected;
        }

        return $incidents;
    }
90637
public function column(string $componentId) : TableComponentMappingDefiner
    {
        /** @var IColumn $column */
        /** @var IColumnComponent $component */
        list($column, $component) = $this->tableDataSource->getStructure()->getColumnAndComponent($componentId);
        $componentId = $column->getName() . '.' . $component->getName();

        return new TableComponentMappingDefiner($component, function (IColumnComponent $chartAxisComponent) use ($column, $componentId) {
            $this->chartComponentTableIdMap[$chartAxisComponent] = $componentId;
            $this->addColumnToLoad($column);
        });
    }
878187
private function resolveStorageId(string $key, string $componentId): string
    {
        return sprintf('%s.%s', rtrim($key, 's'), $componentId);
    }
401857
public function getEnabledComponents()
    {
        // Answer Cached Components (if available):
        
        if ($this->cacheEnabledComponents) {
            return $this->cacheEnabledComponents;
        }
        
        // Obtain Component Objects:
        
        $components = ArrayList::create();
        
        foreach ($this->getEnabledChildren() as $child) {
            $components->push($child);
            $components->merge($child->getEnabledComponents());
        }
        
        $this->cacheEnabledComponents = $components;
        
        // Answer Component Objects:
        
        return $this->cacheEnabledComponents;
    }
1152689
public function getComponents()
    {
        $components = [];

        foreach ($this->indexReverse[self::COMPONENT] as $index) {
            $components[] = $this->getChild($index);
        }

        return $components;
    }
306945
public function groupBy(string $componentId)
    {
        /** @var IColumn $column */
        list($column, $component) = $this->structure->getColumnAndComponent($componentId);
        $this->groupings[] = new ColumnGrouping($column, $component);

        $this->load($column->getName());

        return $this;
    }
48814
public List<Integer> getComponentTasks(String componentId) {
    List<Integer> retVal = new LinkedList<>();
    for (Map.Entry<Integer, String> entry : taskToComponentMap.entrySet()) {
      if (entry.getValue().equals(componentId)) {
        retVal.add(entry.getKey());
      }
    }
    return retVal;
  }
396014
private function getVersions($class)
    {
        $versions = [
            'versions' => [
                '1.0' => $class
            ],
            'latest'   => '1.0',
            'current'  => '1.0'
        ];

        if (method_exists($class, 'getAllVersions')) {
            // all versions
            $interfaceVersions = $class::getAllVersions();
            if (count($interfaceVersions) > 0) {
                $versions = ['versions' => $interfaceVersions];
            }

            // current
            $interfaceCurrent = $class::getCurrentVersion();
            if (!empty($interfaceCurrent)) {
                $versions['current'] = $interfaceCurrent;
            } else {
                $ak = array_keys($versions['versions']);
                $versions['current'] = end($ak);
            }

            // latest
            $interfaceLatest = $class::getLatestVersion();
            if (!empty($interfaceLatest)) {
                $versions['latest'] = $interfaceLatest;
            } else {
                $ak = array_keys($versions['versions']);
                $versions['latest'] = end($ak);
            }
        }

        return $versions;
    }
55320
public function average(string $componentId) : ColumnMappingDefiner
    {
        return $this->aggregate($componentId, function (array $values) {
            return (float)(array_sum($values) / count($values));
        });
    }
97273
private function loadVersionInfo($contentId): VersionInfo
    {
        return $this->repository->sudo(
            static function (Repository $repository) use ($contentId): VersionInfo {
                return $repository->getContentService()->loadVersionInfoById($contentId);
            }
        );
    }
161097
public function get_components() {

		$components = pods_transient_get( 'pods_components' );

		if ( 1 === (int) pods_v( 'pods_debug_components', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
			$components = array();
		}

		if ( PODS_VERSION !== PodsInit::$version || ! is_array( $components ) || empty( $components ) || ( is_admin() && 'pods-components' === pods_v( 'page' ) && 1 !== (int) pods_transient_get( 'pods_components_refresh' ) ) ) {
			do_action( 'pods_components_get' );

			// @codingStandardsIgnoreLine
			$component_dir   = @opendir( untrailingslashit( $this->components_dir ) );
			$component_files = array();

			if ( false !== $component_dir ) {
				$file = readdir( $component_dir );

				while ( false !== $file ) {
					if ( '.' === substr( $file, 0, 1 ) ) {
						// Get next file
						$file = readdir( $component_dir );

						continue;
					} elseif ( is_dir( $this->components_dir . $file ) ) {
						// @codingStandardsIgnoreLine
						$component_subdir = @opendir( $this->components_dir . $file );

						if ( $component_subdir ) {
							$subfile = readdir( $component_subdir );

							while ( false !== $subfile ) {
								if ( '.' === substr( $subfile, 0, 1 ) ) {
									// Get next file
									$subfile = readdir( $component_subdir );

									continue;
								} elseif ( '.php' === substr( $subfile, - 4 ) ) {
									$component_files[] = str_replace( '\\', '/', $file . '/' . $subfile );
								}

								// Get next file
								$subfile = readdir( $component_subdir );
							}

							closedir( $component_subdir );
						}
					} elseif ( '.php' === substr( $file, - 4 ) ) {
						$component_files[] = $file;
					}//end if

					// Get next file
					$file = readdir( $component_dir );
				}//end while

				closedir( $component_dir );
			}//end if

			$default_headers = array(
				'ID'               => 'ID',
				'Name'             => 'Name',
				'ShortName'        => 'Short Name',
				'PluginName'       => 'Plugin Name',
				'ComponentName'    => 'Component Name',
				'URI'              => 'URI',
				'MenuName'         => 'Menu Name',
				'MenuPage'         => 'Menu Page',
				'MenuAddPage'      => 'Menu Add Page',
				'MustUse'          => 'Must Use',
				'Description'      => 'Description',
				'Version'          => 'Version',
				'Category'         => 'Category',
				'Author'           => 'Author',
				'AuthorURI'        => 'Author URI',
				'Class'            => 'Class',
				'Hide'             => 'Hide',
				'PluginDependency' => 'Plugin Dependency',
				'ThemeDependency'  => 'Theme Dependency',
				'DeveloperMode'    => 'Developer Mode',
				'TablelessMode'    => 'Tableless Mode',
				'Capability'       => 'Capability',
				'Plugin'           => 'Plugin',
			);

			$component_files = apply_filters( 'pods_components_register', $component_files );

			$components = array();

			foreach ( $component_files as $component_file ) {
				$external = false;

				if ( is_array( $component_file ) && isset( $component_file['File'] ) ) {
					$component_file = $component_file['File'];
					$component      = $component_file;

					$external = true;
				} else {
					$component = $this->components_dir . $component_file;
				}

				if ( ! is_readable( $component ) ) {
					continue;
				}

				$component_data = get_file_data( $component, $default_headers, 'pods_component' );

				if ( ( empty( $component_data['Name'] ) && empty( $component_data['ComponentName'] ) && empty( $component_data['PluginName'] ) ) || 'yes' === $component_data['Hide'] ) {
					continue;
				}

				if ( isset( $component_data['Plugin'] ) && pods_is_plugin_active( $component_data['Plugin'] ) ) {
					continue;
				}

				if ( empty( $component_data['Name'] ) ) {
					if ( ! empty( $component_data['ComponentName'] ) ) {
						$component_data['Name'] = $component_data['ComponentName'];
					} elseif ( ! empty( $component_data['PluginName'] ) ) {
						$component_data['Name'] = $component_data['PluginName'];
					}
				}

				if ( empty( $component_data['ShortName'] ) ) {
					$component_data['ShortName'] = $component_data['Name'];
				}

				if ( empty( $component_data['MenuName'] ) ) {
					$component_data['MenuName'] = $component_data['Name'];
				}

				if ( empty( $component_data['Class'] ) ) {
					$component_data['Class'] = 'Pods_' . pods_js_name( basename( $component, '.php' ), false );
				}

				if ( empty( $component_data['ID'] ) ) {
					$component_data['ID'] = $component_data['Name'];
				}

				$component_data['ID'] = sanitize_title( $component_data['ID'] );

				if ( 'on' === strtolower( $component_data['DeveloperMode'] ) && '1' === $component_data['DeveloperMode'] ) {
					$component_data['DeveloperMode'] = true;
				} else {
					$component_data['DeveloperMode'] = false;
				}

				if ( 'on' === strtolower( $component_data['TablelessMode'] ) && '1' === $component_data['TablelessMode'] ) {
					$component_data['TablelessMode'] = true;
				} else {
					$component_data['TablelessMode'] = false;
				}

				$component_data['External'] = $external;

				if ( 'on' === strtolower( $component_data['MustUse'] ) || '1' === $component_data['MustUse'] ) {
					$component_data['MustUse'] = true;
				} elseif ( 'off' === strtolower( $component_data['MustUse'] ) || '0' === $component_data['MustUse'] ) {
					$component_data['MustUse'] = false;
				} else {
					$component_data['MustUse'] = $component_data['External'];
				}

				$component_data['File'] = $component_file;

				$components[ $component_data['ID'] ] = $component_data;
			}//end foreach

			ksort( $components );

			pods_transient_set( 'pods_components_refresh', 1, ( 60 * 60 * 12 ) );

			pods_transient_set( 'pods_components', $components );
		}//end if

		if ( 1 === (int) pods_v( 'pods_debug_components', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
			pods_debug( $components );
		}

		$this->components = $components;

		return $this->components;
	}
468017
public function getRevisionById($revisionId)
    {
        $revision = $this->revisions->get($revisionId);

        if ($revision !== null) {
            return $revision; //We get here when rendering an unpublished page version
        }

        foreach ($this->revisions as $revision) {
            if ($revision->getRevisionId() === $revisionId) {
                return $revision; //We get here when publishing a new page version
            }
        }

        return null;
    }
166294
public function getActiveVersion($mixID)
    {
        $queryBuilder = $this->connection->createQueryBuilder();
        $queryBuilder->select(['select']);
        $queryBuilder->from('tl_version');
        $queryBuilder->andWhere($queryBuilder->expr()->eq('tl_version.pid', ':pid'));
        $queryBuilder->setParameter(':pid', $mixID);
        $queryBuilder->andWhere($queryBuilder->expr()->eq('tl_version.fromTable', ':fromTable'));
        $queryBuilder->setParameter(':fromTable', $this->source);
        $queryBuilder->andWhere($queryBuilder->expr()->eq('tl_version.active', ':active'));
        $queryBuilder->setParameter(':active', 1);

        $statement = $queryBuilder->execute();
        if (0 === $statement->rowCount()) {
            return null;
        }

        return $statement->fetch(\PDO::FETCH_OBJ)->version;
    }
1107763
public function setQuantityAllocation($subscriptionId, $componentId)
    {
        $service       = $this->getService();
        $rawData       = $this->getRawData(array('component' => $this->_params));
        $response      = $service->request('subscriptions/' . (int)$subscriptionId . '/components/' . (int)$componentId, 'PUT', $rawData);
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }