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)); } } }
public function save() { Piwik::checkUserHasAdminAccess($this->idSite); $typeManager = new TypeManager(); $type = $typeManager->getType($this->idType); /** * Triggered just before Measurable settings are about to be saved. You can use this event for example * to validate not only one setting but multiple ssetting. For example whether username * and password matches. * * @since Piwik 2.14.0 * @deprecated will be removed in Piwik 3.0.0 * * @param MeasurableSettings $this * @param \Piwik\Measurable\Type $type * @param int $idSite */ Piwik::postEvent('Measurable.beforeSaveSettings', array($this, $type, $this->idSite)); $this->storage->save(); }