Giter Club home page Giter Club logo

filefill's Introduction

TYPO3 Extension filefill

Latest Stable Version Build Status StyleCI

Find and fetch missing local files from different remotes.

Ever tried to set up a new system as copy from an existing one? Wondered if all the files (in fileadmin) are really needed? Ever run into the problem that a local file was missing?

Filefill fetches missing files from one or multiple remote servers to ensure you have all the files you need for the new system.

The extension requires the usage of FAL api to fetch missing files. Files are stored directly in the (local) storage folder (e.g. fileadmin). You can re-run filefill at any time by deleting the local files in the storage folder.

Installation

Simply install the extension with Composer or the Extension Manager.

composer require ichhabrecht/filefill

Usage

You need to configure resources for one or more existing file storages.

Prerequisite: Only storages with a "Local filesystem" driver are currently supported.

Resources for file storages can be configured using one of the two following options where the database record configuration is preferred if set. If not set, the TYPO3_CONF_VARS configuration is used.

Database record configuration

  • go to the root of your TYPO3 page tree (id=0)
  • change to the list module (Web -> List on the left side)
  • find the "File Storage" section and edit a record
  • change to the tab "File Fill" and select the enable checkbox
  • define the resource chain that should be used to fetch missing files

TYPO3_CONF_VARS configuration

  • given a file storage with uid 1, the configuration might look like this
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['storages'][1] = [
    [
        'identifier' => 'domain',
        'configuration' => 'https://example.com',
    ],
    [
        'identifier' => 'domain',
        'configuration' => 'https://another-example.com',
    ],
    [
        'identifier' => 'sys_domain',
    ],
    [
        'identifier' => 'placeholder',
    ],
];
  • you don't need to configure resources that you don't want to use
  • the ordering in your configuration defines the ordering of processing

Resources

Resources define the places (url / services) where filefill tries to fetch missing files from. You can use multiple resources to build some kind of fallback chain.

Single domain

Fetch missing files from a fixed url.

Configuration:

  • Url: Enter a valid url (incl http/https scheme)

You can use multiple single domains within one resources configuration.

Domain records

Fetch missing files from all available site configurations. Filefill runs through all base and variant urls as long as the file can be fetched or all domains are processed.

Configuration:

  • no configuration required (the checkbox is just a field placeholder)

There is no need for multiple usage. All domains are used by default.

Placeholder.com

Fetch a missing image from the placeholder.com service. This fetches an image with the correct resolution of the original file.

Configuration:

  • no configuration required (the checkbox is just a field placeholder)

There is no need for multiple usage. This resource can be the last one in the chain but can handle image files only.

Additional resources

You can add own resource handlers to fetch files from additional services.

Registration

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['filefill']['resourceHandler']['identifierName'] = [
    'title' => 'Name of the resource',
    'handler' => \Vendor\Extension\Resource\ResourceHandler::class,
    'config' => [
        'label' => 'Name of the resource',
        'config' => [
            'type' => 'check',
            'default' => 1,
        ],
    ],
];
  • title: name of the resource that is taken as backend (flex) button label
  • handler: name of the class that handels the actual implementation
  • config: TCA configuration for the backend (flex) field

Handler

namespace Vendor\Extension\Resource;
class ResourceHandler implements \IchHabRecht\Filefill\Resource\RemoteResourceInterface
{
    public function hasFile($fileIdentifier, $filePath, FileInterface $fileObject = null)
    {
        return true;
    }

    public function getFile($fileIdentifier, $filePath, FileInterface $fileObject = null)
    {
        return 'file content';
    }
}

The handler needs to implement the interface \IchHabRecht\Filefill\Resource\RemoteResourceInterface and therefore has to add both functions hasFile and getFile.

Debugging

You can enable additional log information by configuring a filefill logger.

$GLOBALS['TYPO3_CONF_VARS']['LOG']['IchHabRecht']['Filefill'] = [
    'writerConfiguration' => [
        \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
            \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
                'logFileInfix' => 'filefill',
            ],
        ],
    ],
];

Known issues

1509741907 TYPO3Fluid\Fluid\Core\ViewHelper\Exception

Folder "[...]" does not exist.

Filefill tries to fetch the existing file from any resource. However, due to the FAL api the exception cannot be prevented nor handled by filefill. Try to reload the page again, the exception (for this specific file) should not occur anymore. Please note that there might be a new exception for a new file. In this case you need to reload your page until all files were properly created on your current system.

Community

filefill's People

Contributors

ichhabrecht avatar randomresult avatar julianhofmann avatar bjo3rnf avatar franzkugelmann avatar helhum avatar mbrodala avatar dogawaf avatar kaywalker avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.