Piwik\Measurable\Type\TypeManager::getType PHP Method

getType() public method

public getType ( string $typeId ) : Type | null
$typeId string
return Piwik\Measurable\Type | null
    public function getType($typeId)
    {
        foreach ($this->getAllTypes() as $type) {
            if ($type->getId() === $typeId) {
                return $type;
            }
        }
        return new Type();
    }

Usage Example

Ejemplo n.º 1
0
Archivo: Menu.php Proyecto: piwik/piwik
 private function getFirstTypeIfOnlyOneIsInUse()
 {
     $types = $this->typeManager->getAllTypes();
     if (count($types) === 1) {
         // only one type is in use, use this one for the wording
         return reset($types);
     } else {
         // multiple types are activated, check whether only one is actually in use
         $model = new Model();
         $typeIds = $model->getUsedTypeIds();
         if (count($typeIds) === 1) {
             $typeManager = new TypeManager();
             return $typeManager->getType(reset($typeIds));
         }
     }
 }
All Usage Examples Of Piwik\Measurable\Type\TypeManager::getType