/** * @param User $user * @param boolean $hydrate * @return UserDirectory|null */ public function getRootDir($user, $hydrate = true) { return $this->createQueryBuilder('d')->where('d.userId = :user_id AND d.isRoot = 1')->setParameter('user_id', $user->getId())->setMaxResults(1)->getQuery()->getOneOrNullResult($hydrate === true ? Query::HYDRATE_OBJECT : Query::HYDRATE_ARRAY); }
public function changeBckImage(UserFile $image, User $user) { $webpath = '/files/resources/desktop-images/' . $user->getUsername() . '/'; $apppath = __DIR__ . '/../../../../web'; $fs = new Filesystem(); if ($this->getBackgroundImage() !== ServerConstants::DEFAULT_BACKGROUND_IMAGE) { $fs->remove($apppath . $this->getBackgroundImage()); } $fs->copy($apppath . $image->getWebPath(), $apppath . $webpath . $image->getName()); $this->setBackgroundImage($webpath . $image->getName()); return $this; }