Example #1
0
 /**
  * Возвращает проект по ссылке
  *
  * @param ProjectLink $project_link
  * @return \ItBlaster\MainBundle\Model\Project
  */
 private function getProjectByLink(ProjectLink $project_link)
 {
     $project = $project_link->getProject();
     if (!$project) {
         throw $this->createNotFoundException('Project not fonud');
     }
     $this->checkPermissions($project);
     return $project;
 }
Example #2
0
 /**
  * Обновление информации по ссылке
  *
  * @param ProjectLink $project_link
  * @return ProjectLink
  * @throws \Exception
  * @throws \PropelException
  */
 public function updateLink(ProjectLink $project_link, $custom_port = false, $curlopt_timeout = 15)
 {
     $link = $project_link->getLink();
     $info = $this->getCurlInfo($link, $custom_port, $curlopt_timeout);
     $project_link->setStatus($info['http_code'] == '200')->setStatusCode($info['http_code'])->setLastCheck(time())->setTotalTime($info['total_time']);
     if ($info['http_code'] == '301') {
         $project_link->setRedirectUrl($info['redirect_url']);
     }
     $project_link->save();
     return $project_link;
 }
Example #3
0
 /**
  * Добавление ссылки в проект
  *
  * @param $link
  * @param $title
  * @return mixed
  * @throws \Exception
  * @throws \PropelException
  */
 public function addLink($link, $title)
 {
     $project_link = new ProjectLink();
     $project_link->setLink($link)->setTitle($title)->setActive(true)->setProject($this)->save();
     return $link;
 }
 /**
  * Создание объекта "ссылка проекта" в базе
  *
  * @param $form
  * @param Project $project
  * @return ProjectLink
  * @throws \Exception
  * @throws \PropelException
  */
 private function addProjectLink($form, Project $project)
 {
     $data = $form->getData();
     $link = new ProjectLink();
     $link->setProject($project)->setTitle($data['title'])->setLink($data['link'])->setActive(true)->save();
     return $link;
 }