class PackerFile (View source)

Constants

TYPE_OTHER

File type: other.

TYPE_TRANSLATIONS_POT

File type: source .pot translation file.

TYPE_TRANSLATIONS_PO

File type: source .po translation file.

TYPE_SVGICON_PACKAGE

File type: package source .svg icon file.

TYPE_SVGICON_BLOCKTYPE

File type: block type source .svg icon file.

TYPE_SVGICON_THEME

File type: theme source .svg icon file.

Properties

private string $absolutePath

The absolute path to the actual file/directory (with directory separators normalized to '/', without trailing slashes).

private string $relativePath

The path to the file/directory relative to the package root directory (with directory separators normalized to '/', without trailing slashes).

private bool $isDirectory

Is this a directory?

private bool $isModified

Is this a file that has been modified?

private string|null $basename

The name of the file/directory, without the path.

private string|null $extension

The extension of the file, lower case without the leading dot.

private int|null $type

The type of the file (one of the TYPE_... constants).

Methods

__construct(string $absolutePath, string $relativePath, bool $isDirectory, bool $isModified)

Initialize the instance.

static PackerFile
fromSourceFileInfo(string $basePath, SplFileInfo $fileInfo)

Create a new instance of a file/directory as read from the source package directory (marking it as not changed).

static PackerFile
newChangedFile(PackerFile $originalFile, string $actualSourcePath)

Create a new instance of a file, representing a replacement for an existing original package file.

static 
newlyCreatedFile(string $absolutePath, string $relativePath)

Create a new instance of a file, representing a new file added to the package directory.

string
getAbsolutePath()

Get the absolute path to the actual file/directory (with directory separators normalized to '/', without trailing slashes).

string
getAbsolutePathWithExtension(string $newExtension)

Generate a new absolute path, with a new file extension.

string
getRelativePath()

Get the path to the file/directory relative to the package root directory (with directory separators normalized to '/', without trailing slashes).

string
getRelativePathWithExtension(string $newExtension)

Generate a new relative path, with a new file extension.

bool
isDirectory()

Is this a directory?

bool
isModified()

Is this a file that has been modified?

string
getBasename()

The name of the file/directory, without the path.

string
getExtension()

Get the extension of the file, lower case without the leading dot.

int
getType()

Get the type of the file (one of the TYPE_... constants).

string
getPathWithExtension(string $myPath, string $newExtension)

Change the extension of a path.

Details

protected __construct(string $absolutePath, string $relativePath, bool $isDirectory, bool $isModified)

Initialize the instance.

Parameters

string $absolutePath

the absolute path to the actual file/directory (with directory separators normalized to '/', without trailing slashes)

string $relativePath

the path to the file/directory relative to the package root directory

bool $isDirectory

TRUE if it's a directory, FALSE otherwise

bool $isModified

is this a file that has been modified?

static PackerFile fromSourceFileInfo(string $basePath, SplFileInfo $fileInfo)

Create a new instance of a file/directory as read from the source package directory (marking it as not changed).

Parameters

string $basePath

the absolute path of the package root directory

SplFileInfo $fileInfo

the file/directory

Return Value

PackerFile

Exceptions

InvalidArgumentException

static PackerFile newChangedFile(PackerFile $originalFile, string $actualSourcePath)

Create a new instance of a file, representing a replacement for an existing original package file.

Parameters

PackerFile $originalFile

the original file that's being replaced

string $actualSourcePath

the path to actual file that replaces the original file

Return Value

PackerFile

Exceptions

InvalidArgumentException

static newlyCreatedFile(string $absolutePath, string $relativePath)

Create a new instance of a file, representing a new file added to the package directory.

Parameters

string $absolutePath

the path to actual file that replaces the original file

string $relativePath

the path to of the file relative to the package root directory

string getAbsolutePath()

Get the absolute path to the actual file/directory (with directory separators normalized to '/', without trailing slashes).

Return Value

string

string getAbsolutePathWithExtension(string $newExtension)

Generate a new absolute path, with a new file extension.

Parameters

string $newExtension

Return Value

string

string getRelativePath()

Get the path to the file/directory relative to the package root directory (with directory separators normalized to '/', without trailing slashes).

Return Value

string

string getRelativePathWithExtension(string $newExtension)

Generate a new relative path, with a new file extension.

Parameters

string $newExtension

Return Value

string

bool isDirectory()

Is this a directory?

Return Value

bool

bool isModified()

Is this a file that has been modified?

Return Value

bool

string getBasename()

The name of the file/directory, without the path.

Return Value

string

string getExtension()

Get the extension of the file, lower case without the leading dot.

Lower case, wihout dot.

Return Value

string

int getType()

Get the type of the file (one of the TYPE_... constants).

Return Value

int

protected string getPathWithExtension(string $myPath, string $newExtension)

Change the extension of a path.

Parameters

string $myPath
string $newExtension

Return Value

string