Finds the module associated with the given type and returns an instance
@param string $type The module type
@param ModuleLocation $location The location; either backend or frontend
@return ModuleBase
967609
static function CreateModule($type, ModuleLocation $location)
    {
        $class = self::ModuleClass($type, $location);
        if (!class_exists($class))
        {
            return null;
        }
        return new $class();
    }
915435
public function transform(LocationInterface $location)
    {
        return $this
            ->locationDataFactory
            ->create(
                $location->getId(),
                $location->getName(),
                $location->getCode(),
                $location->getType()
            );
    }
7006
public function load($resource, $type = null)
    {
        if ($this->loaded) {
            throw new \RuntimeException('Do not add this loader twice');
        }

        $collection = new RouteCollection();

        foreach ($this->container->getParameter('smart_core_cms.modules') as $moduleName => $module) {
            $resource = $module['path'].'/Resources/config/routing_admin.yml';
            if (file_exists($resource)) {
                $importedRoutes = $this->import('@'.$moduleName.'ModuleBundle/Resources/config/routing_admin.yml', 'yaml');
                $importedRoutes->addPrefix($moduleName);

                $collection->addCollection($importedRoutes);
            }
        }

        return $collection;
    }
1371992
public function addLocation($location)
    {
        $loader = new \Mustache_Loader_FilesystemLoader($location);
        if ($this->mustache->getLoader() instanceof \Mustache_Loader_CascadingLoader) {
            $this->mustache->getLoader()->addLoader( $loader);
        } else {
            $loaders = [$this->mustache->getLoader(), $loader];
            $this->mustache->setLoader(new \Mustache_Loader_CascadingLoader($loaders));
        }
        return $this;
    }
851768
private function performMoveMedia($type, $location, $oldName, $newName)
    {
        $from = "{$location}/{$oldName}";

        switch (Str::lower($type)) {
            case Media::MEDIA_TYPE_FILE:
                return $this->moveFile($from, $location, $newName);

            case Media::MEDIA_TYPE_DIRECTORY:
                return $this->moveDirectory($from, $location, $newName);

            default:
                return false;
        }
    }
414978
private function compareType($module, $type)
    {
        $res = array();
        
        try {
            $od = ObjectDefinition::findByTable($type['name']);
        } 
		catch (\Exception $e) {
      		  $res[] = array(
      				'error'  => self::TYPE_NOT_EXISTS,
      				'table'  => $type['name'],
      				'module' => $module
      		  );
      		  return $res;        
        }
        
        if (is_array($type['fields'])) foreach ($type['fields'] as $field) {
            try {
                $f = $od->getField($field['name']);
                
          		foreach ($field as $prop => $value) 
				{
						if ($prop == 'description') continue;
						if ($prop == 'editor_user') continue;
						if ($prop == 'fixed') continue;
						if (!$f['fixed']) {
						    if ($prop == 'editor') continue;
						}
						
						if ( $prop == 'length' && !(int)$value )
						{
							$_od = ObjectDefinition::findById($f[$prop]);
							$f[$prop] = $_od->alias;
						}
						
						if ($value != $f[$prop]) {
									$res[] = array(
										'error'    => self::TYPE_FIELD_DONT_MATCH,
										'field'    => $field['name'],
										'table'    => $type['name'],
										'module'   => $module,
										'expected' => $prop.' => '.$value,
										'found'    => $prop.' => '.$f[$prop],
									);
						}
                }                
            } 
			catch (\Exception $e)
			{
        			  $res[] = array(
          					'error'  => self::TYPE_FIELD_NOT_FOUND,
          					'field'  => $field['name'],
          					'table'  => $type['name'],
          					'module' => $module
        				);      
            }
                    
        }
        
        return $res;
    
    }
420215
public static function findByType( $type, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'type=:type AND siteId=:siteId', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
		}
		else {

			return static::find()->where( 'type=:type', [ ':type' => $type ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
		}
	}
43527
public function supports($resource, $type = null)
    {
        try {
            $path = $this->locator->locate($resource);
        } catch (\Exception $e) {
            return false;
        }

        return 'module' === $type && is_string($resource) && is_dir($path);
    }
1189150
private function createRestLocation(Location $location): RestLocation
    {
        return new RestLocation(
            $location,
            $this->locationService->getLocationChildCount($location)
        );
    }
828429
public function create($type)
    {
        $typeOptions    = $this->getOption(self::OPTION_MAPPERS);
        $typeOption     = isset($typeOptions[$type]) ? $typeOptions[$type] : $this->throwException();
        $importerString = isset($typeOption[self::OPTION_MAPPERS_IMPORTER]) ? $typeOption[self::OPTION_MAPPERS_IMPORTER] : $this->throwException();
        $importer       = $this->buildService($importerString, ImportServiceInterface::class);

        if (isset($typeOption[self::OPTION_MAPPERS_MAPPER])) {
            $mapperString = $typeOption[self::OPTION_MAPPERS_MAPPER];
            $mapper       = $this->buildService($mapperString);
        } else {
            $mapper = $this->getDefaultMapper();
        }

        $this->propagate($mapper);
        $importer->setMapper($mapper);

        return $importer;
    }
640320
public function matchLocation(APILocation $location)
    {
        $parentContentType = $this->repository->sudo(
            function (Repository $repository) use ($location) {
                $parent = $repository->getLocationService()->loadLocation($location->parentLocationId);

                return $repository
                    ->getContentTypeService()
                    ->loadContentType($parent->getContentInfo()->contentTypeId);
            }
        );

        return isset($this->values[$parentContentType->identifier]);
    }
121191
private function getSearchQuery(Location $parentLocation): LocationQuery
    {
        $searchQuery = new LocationQuery();
        $searchQuery->filter = new Criterion\ParentLocationId($parentLocation->id);

        $contentTypeCriterion = null;

        if (!empty($this->allowedContentTypes)) {
            $contentTypeCriterion = new Criterion\ContentTypeIdentifier($this->allowedContentTypes);
        }

        if (empty($this->allowedContentTypes) && !empty($this->ignoredContentTypes)) {
            $contentTypeCriterion = new Criterion\LogicalNot(
                new Criterion\ContentTypeIdentifier($this->ignoredContentTypes)
            );
        }

        if (null !== $contentTypeCriterion) {
            $searchQuery->filter = new Criterion\LogicalAnd([$searchQuery->filter, $contentTypeCriterion]);
        }

        return $searchQuery;
    }
926467
public function factory($module, $action)
    {
        if (empty($module) || empty($action)) {
            return;
        }

        try {
            if (!$this->pluginManager->isPluginActivated($module)) {
                return;
            }

            $plugin = $this->pluginManager->getLoadedPlugin($module);
        } catch (\Exception $e) {
            // we are not allowed to use possible widgets, plugin is not active
            return;
        }

        /** @var Widget[] $widgetContainer */
        $widgets = $plugin->findMultipleComponents('Widgets', 'Piwik\\Widget\\Widget');

        foreach ($widgets as $widgetClass) {
            $config = $this->getWidgetConfigForClassName($widgetClass);
            if ($config->getAction() === $action) {
                $config->checkIsEnabled();
                return StaticContainer::get($widgetClass);
            }
        }
    }
856231
public function getHandler( Location $location )
    {
        $locationContentTypeId = $location->contentInfo->contentTypeId;

        /** @var ContentType $locationContentType */
        $locationContentType = $this->contentTypeService->loadContentType( $locationContentTypeId );

        return array_key_exists( $locationContentType->identifier, $this->map ) ?
            $this->map[$locationContentType->identifier] :
            new NullHandler();
    }
516985
public function matchLocation(Location $location)
    {
        $section = $this->repository->sudo(
            function (Repository $repository) use ($location) {
                return $repository->getSectionService()->loadSection(
                    $location->getContentInfo()->sectionId
                );
            }
        );

        return isset($this->values[$section->identifier]);
    }
1048836
protected function getLocationPattern($frameworkType)
    {
        $pattern = false;
        if (!empty($this->supportedTypes[$frameworkType])) {
            $frameworkClass = 'Eccube2\\Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
            /** @var BaseInstaller $framework */
            $framework = new $frameworkClass(null, $this->composer, $this->getIO());
            $locations = array_keys($framework->getLocations());
            $pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
        }

        return $pattern ? $pattern : '(\w+)';
    }
864472
public static function factory($module, $action)
    {
        $listApiToReport = self::getMapOfModuleActionsToReport();
        $api = $module . '.' . ucfirst($action);

        if (!array_key_exists($api, $listApiToReport)) {
            return null;
        }

        $klassName = $listApiToReport[$api];

        return new $klassName;
    }