本文整理汇总了PHP中collection::update_logo方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::update_logo方法的具体用法?PHP collection::update_logo怎么用?PHP collection::update_logo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::update_logo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdate_logo
public function testUpdate_logo()
{
$pathfile = new \SplFileInfo(__DIR__ . '/../files/logocoll.gif');
self::$object->update_logo($pathfile);
$this->assertEquals(file_get_contents($pathfile->getPathname()), self::$object->get_binary_minilogos());
}
示例2: write_collection_pic
public function write_collection_pic(Alchemyst $alchemyst, Filesystem $filesystem, collection $collection, SymfoFile $pathfile = null, $pic_type)
{
$filename = null;
if (!is_null($pathfile)) {
if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'])) {
throw new \InvalidArgumentException('Invalid file format');
}
$filename = $pathfile->getPathname();
if ($pic_type === collection::PIC_LOGO) {
//resize collection logo
$imageSpec = new ImageSpecification();
$media = $this->app['mediavorus']->guess($filename);
if ($media->getWidth() > 120 || $media->getHeight() > 24) {
$imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
$imageSpec->setDimensions(120, 24);
}
$tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg';
try {
$alchemyst->turninto($pathfile->getPathname(), $tmp, $imageSpec);
$filename = $tmp;
} catch (\MediaAlchemyst\Exception $e) {
}
} elseif ($pic_type === collection::PIC_PRESENTATION) {
//resize collection logo
$imageSpec = new ImageSpecification();
$imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
$imageSpec->setDimensions(650, 200);
$tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg';
try {
$alchemyst->turninto($pathfile->getPathname(), $tmp, $imageSpec);
$filename = $tmp;
} catch (\MediaAlchemyst\Exception $e) {
}
}
}
switch ($pic_type) {
case collection::PIC_WM:
$collection->reset_watermark();
break;
case collection::PIC_LOGO:
case collection::PIC_PRESENTATION:
break;
case collection::PIC_STAMP:
$collection->reset_stamp();
break;
default:
throw new \InvalidArgumentException('unknown pic_type');
break;
}
if ($pic_type == collection::PIC_LOGO) {
$collection->update_logo($pathfile);
}
$file = $this->app['root.path'] . '/config/' . $pic_type . '/' . $collection->get_base_id();
$custom_path = $this->app['root.path'] . '/www/custom/' . $pic_type . '/' . $collection->get_base_id();
foreach ([$file, $custom_path] as $target) {
if (is_file($target)) {
$filesystem->remove($target);
}
if (null === $target || null === $filename) {
continue;
}
$filesystem->mkdir(dirname($target), 0750);
$filesystem->copy($filename, $target, true);
$filesystem->chmod($target, 0760);
}
return $this;
}