Loading core/modules/file/src/Entity/File.php +4 −2 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ public function setMimeType($mime) { * {@inheritdoc} */ public function getSize() { return $this->get('filesize')->value; $filesize = $this->get('filesize')->value; return isset($filesize) ? (int) $filesize : NULL; } /** Loading @@ -127,7 +128,8 @@ public function setSize($size) { * {@inheritdoc} */ public function getCreatedTime() { return $this->get('created')->value; $created = $this->get('created')->value; return isset($created) ? (int) $created : NULL; } /** Loading core/modules/file/src/FileInterface.php +21 −17 Original line number Diff line number Diff line Loading @@ -28,25 +28,27 @@ interface FileInterface extends ContentEntityInterface, EntityChangedInterface, * This may differ from the basename of the URI if the file is renamed to * avoid overwriting an existing file. * * @return string * Name of the file. * @return string|null * Name of the file, or NULL if unknown. */ public function getFilename(); /** * Sets the name of the file. * * @param string $filename * The file name that corresponds to this file. May differ from the basename * of the URI and changing the filename does not change the URI. * @param string|null $filename * The file name that corresponds to this file, or NULL if unknown. May * differ from the basename of the URI and changing the filename does not * change the URI. */ public function setFilename($filename); /** * Returns the URI of the file. * * @return string * The URI of the file, e.g. public://directory/file.jpg. * @return string|null * The URI of the file, e.g. public://directory/file.jpg, or NULL if it has * not yet been set. */ public function getFileUri(); Loading Loading @@ -75,32 +77,34 @@ public function createFileUrl($relative = TRUE); /** * Returns the MIME type of the file. * * @return string * The MIME type of the file, e.g. image/jpeg or text/xml. * @return string|null * The MIME type of the file, e.g. image/jpeg or text/xml, or NULL if it * could not be determined. */ public function getMimeType(); /** * Sets the MIME type of the file. * * @param string $mime * The MIME type of the file, e.g. image/jpeg or text/xml. * @param string|null $mime * The MIME type of the file, e.g. image/jpeg or text/xml, or NULL if it * could not be determined. */ public function setMimeType($mime); /** * Returns the size of the file. * * @return string * The size of the file in bytes. * @return int|null * The size of the file in bytes, or NULL if it could not be determined. */ public function getSize(); /** * Sets the size of the file. * * @param int $size * The size of the file in bytes. * @param int|null $size * The size of the file in bytes, or NULL if it could not be determined. */ public function setSize($size); Loading Loading @@ -133,8 +137,8 @@ public function setTemporary(); /** * Returns the file entity creation timestamp. * * @return int * Creation timestamp of the file entity. * @return int|null * Creation timestamp of the file entity, or NULL if unknown. */ public function getCreatedTime(); Loading core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ protected function getFileMigrationInfo() { * Tests that all expected files are migrated. */ public function testFileMigration() { $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', '3620', '1421727515', '1421727515', '1'); $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', 3620, 1421727515, '1421727515', '1'); // Ensure temporary file was not migrated. $this->assertNull(File::load(4)); } Loading core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public function register(ContainerBuilder $container) { * Tests that all expected files are migrated. */ public function testFileMigration() { $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', '3', '1486104045', '1486104045', '1'); $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', 3, 1486104045, '1486104045', '1'); } } core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureD6FileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public function testUserPictures() { $this->assertSame('image-test.jpg', $file->getFilename()); $this->assertSame('public://image-test.jpg', $file->getFileUri()); $this->assertSame('2', $file->getOwnerId()); $this->assertSame('1901', $file->getSize()); $this->assertSame(1901, $file->getSize()); $this->assertSame('image/jpeg', $file->getMimeType()); $file = array_shift($files); Loading Loading
core/modules/file/src/Entity/File.php +4 −2 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ public function setMimeType($mime) { * {@inheritdoc} */ public function getSize() { return $this->get('filesize')->value; $filesize = $this->get('filesize')->value; return isset($filesize) ? (int) $filesize : NULL; } /** Loading @@ -127,7 +128,8 @@ public function setSize($size) { * {@inheritdoc} */ public function getCreatedTime() { return $this->get('created')->value; $created = $this->get('created')->value; return isset($created) ? (int) $created : NULL; } /** Loading
core/modules/file/src/FileInterface.php +21 −17 Original line number Diff line number Diff line Loading @@ -28,25 +28,27 @@ interface FileInterface extends ContentEntityInterface, EntityChangedInterface, * This may differ from the basename of the URI if the file is renamed to * avoid overwriting an existing file. * * @return string * Name of the file. * @return string|null * Name of the file, or NULL if unknown. */ public function getFilename(); /** * Sets the name of the file. * * @param string $filename * The file name that corresponds to this file. May differ from the basename * of the URI and changing the filename does not change the URI. * @param string|null $filename * The file name that corresponds to this file, or NULL if unknown. May * differ from the basename of the URI and changing the filename does not * change the URI. */ public function setFilename($filename); /** * Returns the URI of the file. * * @return string * The URI of the file, e.g. public://directory/file.jpg. * @return string|null * The URI of the file, e.g. public://directory/file.jpg, or NULL if it has * not yet been set. */ public function getFileUri(); Loading Loading @@ -75,32 +77,34 @@ public function createFileUrl($relative = TRUE); /** * Returns the MIME type of the file. * * @return string * The MIME type of the file, e.g. image/jpeg or text/xml. * @return string|null * The MIME type of the file, e.g. image/jpeg or text/xml, or NULL if it * could not be determined. */ public function getMimeType(); /** * Sets the MIME type of the file. * * @param string $mime * The MIME type of the file, e.g. image/jpeg or text/xml. * @param string|null $mime * The MIME type of the file, e.g. image/jpeg or text/xml, or NULL if it * could not be determined. */ public function setMimeType($mime); /** * Returns the size of the file. * * @return string * The size of the file in bytes. * @return int|null * The size of the file in bytes, or NULL if it could not be determined. */ public function getSize(); /** * Sets the size of the file. * * @param int $size * The size of the file in bytes. * @param int|null $size * The size of the file in bytes, or NULL if it could not be determined. */ public function setSize($size); Loading Loading @@ -133,8 +137,8 @@ public function setTemporary(); /** * Returns the file entity creation timestamp. * * @return int * Creation timestamp of the file entity. * @return int|null * Creation timestamp of the file entity, or NULL if unknown. */ public function getCreatedTime(); Loading
core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ protected function getFileMigrationInfo() { * Tests that all expected files are migrated. */ public function testFileMigration() { $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', '3620', '1421727515', '1421727515', '1'); $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', 3620, 1421727515, '1421727515', '1'); // Ensure temporary file was not migrated. $this->assertNull(File::load(4)); } Loading
core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public function register(ContainerBuilder $container) { * Tests that all expected files are migrated. */ public function testFileMigration() { $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', '3', '1486104045', '1486104045', '1'); $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', 3, 1486104045, '1486104045', '1'); } }
core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureD6FileTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public function testUserPictures() { $this->assertSame('image-test.jpg', $file->getFilename()); $this->assertSame('public://image-test.jpg', $file->getFileUri()); $this->assertSame('2', $file->getOwnerId()); $this->assertSame('1901', $file->getSize()); $this->assertSame(1901, $file->getSize()); $this->assertSame('image/jpeg', $file->getMimeType()); $file = array_shift($files); Loading