getModuleName() public méthode

Returns the module name.
public getModuleName ( ) : string | null
Résultat string | null The module name or `null` if none is set.
Exemple #1
0
 /**
  * Creates a new module.
  *
  * @param ModuleFile|null  $moduleFile  The module file or `null` if the
  *                                      module file could not be loaded.
  * @param string           $installPath The absolute install path.
  * @param InstallInfo|null $installInfo The install info of this module.
  * @param Exception[]      $loadErrors  The errors that happened during
  *                                      loading of the module, if any.
  */
 public function __construct(ModuleFile $moduleFile = null, $installPath, InstallInfo $installInfo = null, array $loadErrors = array())
 {
     Assert::absoluteSystemPath($installPath);
     Assert::allIsInstanceOf($loadErrors, 'Exception');
     // If a module name was set during installation, that name wins over
     // the predefined name in the puli.json file (if any)
     $this->name = $installInfo && null !== $installInfo->getModuleName() ? $installInfo->getModuleName() : ($moduleFile ? $moduleFile->getModuleName() : null);
     if (null === $this->name) {
         $this->name = $this->getDefaultName();
     }
     // The path is stored both here and in the install info. While the
     // install info contains the path as it is stored in the install file
     // (i.e. relative or absolute), the install path of the module is
     // always an absolute path.
     $this->installPath = $installPath;
     $this->installInfo = $installInfo;
     $this->moduleFile = $moduleFile;
     $this->loadErrors = $loadErrors;
     if (!file_exists($installPath)) {
         $this->state = ModuleState::NOT_FOUND;
     } elseif (count($loadErrors) > 0) {
         $this->state = ModuleState::NOT_LOADABLE;
     } else {
         $this->state = ModuleState::ENABLED;
     }
 }
Exemple #2
0
 protected function addModuleFileToJson(ModuleFile $moduleFile, stdClass $jsonData)
 {
     $mappings = $moduleFile->getPathMappings();
     $bindingDescriptors = $moduleFile->getBindingDescriptors();
     $typeDescriptors = $moduleFile->getTypeDescriptors();
     $dependencies = $moduleFile->getDependencies();
     $extra = $moduleFile->getExtraKeys();
     if (null !== $moduleFile->getModuleName()) {
         $jsonData->name = $moduleFile->getModuleName();
     }
     if (count($mappings) > 0) {
         $jsonData->resources = new stdClass();
         foreach ($mappings as $mapping) {
             $puliPath = $mapping->getRepositoryPath();
             $localPaths = $mapping->getPathReferences();
             $jsonData->resources->{$puliPath} = count($localPaths) > 1 ? $localPaths : reset($localPaths);
         }
     }
     if (count($bindingDescriptors) > 0) {
         uasort($bindingDescriptors, array(__CLASS__, 'compareBindingDescriptors'));
         $jsonData->bindings = new stdClass();
         foreach ($bindingDescriptors as $bindingDescriptor) {
             $binding = $bindingDescriptor->getBinding();
             $bindingData = new stdClass();
             $bindingData->_class = get_class($binding);
             // This needs to be moved to external classes to allow adding
             // custom binding classes at some point
             if ($binding instanceof ResourceBinding) {
                 $bindingData->query = $binding->getQuery();
                 if ('glob' !== $binding->getLanguage()) {
                     $bindingData->language = $binding->getLanguage();
                 }
             } elseif ($binding instanceof ClassBinding) {
                 $bindingData->class = $binding->getClassName();
             }
             $bindingData->type = $bindingDescriptor->getTypeName();
             // Don't include the default values of the binding type
             if ($binding->hasParameterValues(false)) {
                 $parameterData = $binding->getParameterValues(false);
                 ksort($parameterData);
                 $bindingData->parameters = (object) $parameterData;
             }
             $jsonData->bindings->{$bindingDescriptor->getUuid()->toString()} = $bindingData;
         }
     }
     if (count($typeDescriptors) > 0) {
         $bindingTypesData = array();
         foreach ($typeDescriptors as $typeDescriptor) {
             $type = $typeDescriptor->getType();
             $typeData = new stdClass();
             if ($typeDescriptor->getDescription()) {
                 $typeData->description = $typeDescriptor->getDescription();
             }
             if ($type->hasParameters()) {
                 $parametersData = array();
                 foreach ($type->getParameters() as $parameter) {
                     $parameterData = new stdClass();
                     if ($typeDescriptor->hasParameterDescription($parameter->getName())) {
                         $parameterData->description = $typeDescriptor->getParameterDescription($parameter->getName());
                     }
                     if ($parameter->isRequired()) {
                         $parameterData->required = true;
                     }
                     if (null !== $parameter->getDefaultValue()) {
                         $parameterData->default = $parameter->getDefaultValue();
                     }
                     $parametersData[$parameter->getName()] = $parameterData;
                 }
                 ksort($parametersData);
                 $typeData->parameters = (object) $parametersData;
             }
             $bindingTypesData[$type->getName()] = $typeData;
         }
         ksort($bindingTypesData);
         $jsonData->{'binding-types'} = (object) $bindingTypesData;
     }
     if (count($dependencies) > 0) {
         $jsonData->depend = $dependencies;
     }
     if (count($extra) > 0) {
         $jsonData->extra = (object) $extra;
     }
 }