/** * @param Picture $picture * @param array $data */ protected function postSave(Picture $picture, array $data) { if (isset($data['meta']) && isset($data['meta']['filename'])) { $module = $this->getServiceContainer()->getModuleManager()->load('gossi/trixionary'); $file = new File($module->getUploadPath()->append($data['meta']['filename'])); $slugifier = new Slugify(); $filename = sprintf('%s-%u.%s', $slugifier->slugify($picture->getAthlete()), $picture->getId(), $file->getExtension()); $filepath = $module->getPicturesPath($picture->getSkill())->append($filename); $file->move($filepath); // create thumb folder $thumbspath = $module->getPicturesPath($picture->getSkill())->append('thumbs'); $dir = new Directory($thumbspath); if (!$dir->exists()) { $dir->make(); } // create thumb $imagine = new Imagine(); $image = $imagine->open($filepath->toString()); $max = max($image->getSize()->getWidth(), $image->getSize()->getHeight()); $width = $image->getSize()->getWidth() / $max * self::THUMB_MAX_SIZE; $height = $image->getSize()->getHeight() / $max * self::THUMB_MAX_SIZE; $size = new Box($width, $height); $thumbpath = $thumbspath->append($filename); $image->thumbnail($size)->save($thumbpath->toString()); // save to picture $picture->setUrl($module->getPicturesUrl($picture->getSkill()) . '/' . $filename); $picture->setThumbUrl($module->getPicturesUrl($picture->getSkill()) . '/thumbs/' . $filename); $picture->save(); } // activity $user = $this->getServiceContainer()->getAuthManager()->getUser(); $user->newActivity(array('verb' => $this->isNew ? Activity::VERB_UPLOAD : Activity::VERB_EDIT, 'object' => $picture, 'target' => $picture->getSkill())); }
/** * Filter the query by a related \gossi\trixionary\model\Picture object * * @param \gossi\trixionary\model\Picture|ObjectCollection $picture The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildSkillQuery The current query, for fluid interface */ public function filterByFeaturedPicture($picture, $comparison = null) { if ($picture instanceof \gossi\trixionary\model\Picture) { return $this->addUsingAlias(SkillTableMap::COL_PICTURE_ID, $picture->getId(), $comparison); } elseif ($picture instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(SkillTableMap::COL_PICTURE_ID, $picture->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByFeaturedPicture() only accepts arguments of type \\gossi\\trixionary\\model\\Picture or Collection'); } }
/** * Exclude object from result * * @param ChildPicture $picture Object to remove from the list of results * * @return $this|ChildPictureQuery The current query, for fluid interface */ public function prune($picture = null) { if ($picture) { $this->addUsingAlias(PictureTableMap::COL_ID, $picture->getId(), Criteria::NOT_EQUAL); } return $this; }