本文整理汇总了PHP中Symfony\Component\HttpFoundation\File\File::getFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getFileName方法的具体用法?PHP File::getFileName怎么用?PHP File::getFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\File\File
的用法示例。
在下文中一共展示了File::getFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
//add attachment extend field
self::addAvatarToUser($schema, $this->attachmentExtension);
self::addOwnerToOroFile($schema);
//save old avatars to new place
$em = $this->container->get('doctrine.orm.entity_manager');
$query = "SELECT id, image, createdAt FROM oro_user WHERE image != ''";
$userImages = $em->getConnection()->executeQuery($query)->fetchAll(\PDO::FETCH_ASSOC);
if (!empty($userImages)) {
$maxId = (int) $em->getConnection()->executeQuery('SELECT MAX(id) FROM oro_attachment_file;')->fetchColumn();
foreach ($userImages as $userData) {
$filePath = $this->getUploadFileName($userData);
// file doesn't exists or not readable
if (false === $filePath || !is_readable($filePath)) {
$this->container->get('logger')->addAlert(sprintf('There\'s no image %s for user %d exists.', $userData['image'], $userData['id']));
continue;
}
try {
$this->container->get('oro_attachment.manager')->copyLocalFileToStorage($filePath, $userData['image']);
} catch (\Exception $e) {
$this->container->get('logger')->addError(sprintf('File copy error: %s', $e->getMessage()));
}
$maxId++;
$file = new SymfonyFile($filePath);
$currentDate = new \DateTime();
$query = sprintf('INSERT INTO oro_attachment_file
(id, filename, extension, mime_type, file_size, original_filename,
created_at, updated_at, owner_user_id)
values (%s, \'%s\', \'%s\', \'%s\', %s, \'%s\', \'%s\', \'%s\', %s);', $maxId, $file->getFileName(), $file->guessExtension(), $file->getMimeType(), $file->getSize(), $userData['image'], $currentDate->format('Y-m-d'), $currentDate->format('Y-m-d'), $userData['id']);
$queries->addQuery($query);
$query = sprintf('UPDATE oro_user set avatar_id = %d WHERE id = %d;', $maxId, $userData['id']);
$queries->addQuery($query);
unlink($filePath);
}
}
//delete old avatars field
$schema->getTable('oro_user')->dropColumn('image');
}