/** * Transform to protection model. * * @param Entity $protection * * @return Config[] */ public static function transform(Entity $protection) { $return = array(); $path = sprintf(self::path, $protection->getDomain()->getPath(), $protection->getId()); foreach ($protection->getProtectionuser() as $user) { /** @var EntityUser $user */ $model = new Config(); $model->setUsername($user->getUsername())->setPassword($user->getPassword())->setPath($path)->setId($user->getProtection()->getId()); $return[] = $model; } return $return; }
/** * Create auth user file for given protection. * * @param Protection $protection */ public function createAuthUserFile(Protection $protection) { $path = sprintf('%s/conf/authuser_%s.passwd', $protection->getDomain()->getPath(), $protection->getId()); $content = $this->renderAuthUserFile($this->transformEntity($protection)); file_put_contents($path, $content); }