# FileFactory

Implements \NPS\Factory\IObjectFactory

File factory and file uploader in one place

author | Lukas Korinek
package | Default

### Methods

## __construct

    __construct(\Doctrine\ORM\EntityManagerInterface $em, \NPS\Factory\UserFactory $userFactory, string $mediaPath, string $mediaHiddenUploadsPath, string $mediaBasePath)

### Arguments

#### $em

`\Doctrine\ORM\EntityManagerInterface`

#### $userFactory

`\NPS\Factory\UserFactory`

#### $mediaPath

`string`

Path to publicly available media files

#### $mediaHiddenUploadsPath

`string`

Path to hidden uplaoded media files

#### $mediaBasePath

`string`

URL base path for publicly available media

## Creates (uploads) the file by a path

    createFromPath(integer $id, string $path, \NPS\Model\User $user = null, array $tags, boolean $public, string $note)

### Arguments

#### $id

`integer`

#### $path

`string`

#### $user

`\NPS\Model\User`

#### $tags

`array`

#### $public

`boolean`

#### $note

`string`

## Creates (uploads) the file using symfony request

    createFromRequest(integer $id, \Symfony\Component\HttpFoundation\File\UploadedFile $file, \NPS\Model\User $user = null, array $tags, boolean $public, string $note = NULL)

### Arguments

#### $id

`integer`

#### $file

`\Symfony\Component\HttpFoundation\File\UploadedFile`

#### $user

`\NPS\Model\User`

#### $tags

`array`

#### $public

`boolean`

#### $note

`string`

## Guesses file type based on its MIME

    guessFileType(\Symfony\Component\HttpFoundation\File\UploadedFile $file) : integer

### Arguments

#### $file

`\Symfony\Component\HttpFoundation\File\UploadedFile`

### Response

`integer`

## Loads a factored object from the memory

    load(mixed $entity, \Closure $callback) : mixed

inherited

### Arguments

#### $entity

`mixed`

Entity for which to load the object

#### $callback

`\Closure`

### Response

`mixed`

## Creates an object out of its doctrine entity

    make(\NPS\Entity\IEntity $entity) : \NPS\Model\IDomainObject

inheritDoc |

### Arguments

#### $entity

`\NPS\Entity\IEntity`

Entity object

### Response

`\NPS\Model\IDomainObject`

### Properties

## em

    em : \Doctrine\ORM\EntityManagerInterface

var |

### Type(s)

`\Doctrine\ORM\EntityManagerInterface`

## userFactory

    userFactory : \NPS\Factory\UserFactory

var |

### Type(s)

`\NPS\Factory\UserFactory`

## mediaPath

    mediaPath : string

var |

### Type(s)

`string`

## mediaHiddenPath

    mediaHiddenPath : string

var |

### Type(s)

`string`

## mediaBasePath

    mediaBasePath : string

var |

### Type(s)

`string`

## memory

    memory : array

inherited

var |

### Type(s)

`array`