Пример #1
0
 public function itDoesntReplaceIrrevelantVariables()
 {
     $template_content = "this %projectid% should be replaced by the project name.\n\n            this one %projectid% too!";
     $this->template->setContent($template_content);
     $processed = $this->template_processor->processTemplate($this->template, $this->project);
     $this->assertEqual($template_content, $processed);
 }
Пример #2
0
 /**
  * @param Git_Driver_Gerrit_Template_Template $template
  * @param Project $project
  * @param PFUser $user
  * @throws Git_ProjectNotInHierarchyException
  */
 private function checkTemplateIsAccessible(Git_Driver_Gerrit_Template_Template $template, Project $project, PFUser $user)
 {
     $template_id = $template->getId();
     foreach ($this->template_factory->getTemplatesAvailableForProject($project) as $available_template) {
         if ($available_template->getId() == $template_id) {
             $template_project = $this->project_manager->getProject($available_template->getProjectId());
             $this->checkUserIsAdmin($template_project, $user);
             return true;
         }
     }
     throw new Git_TemplateNotInProjectHierarchyException('Project not in hierarchy', 404);
 }
Пример #3
0
 /**
  * @param Git_Driver_Gerrit_Template_Template $template
  * @return bool
  */
 public function updateTemplate(Git_Driver_Gerrit_Template_Template $template)
 {
     return $this->dao->updateTemplate($template->getId(), $template->getName(), $template->getContent());
 }
 public function processTemplate(Git_Driver_Gerrit_Template_Template $template, Project $project)
 {
     return str_replace(self::PROJECT_NAME_VARIABLE, $project->getUnixName(), $template->getContent());
 }