PHP code example of locomotivemtl / charcoal-contrib-filepond

1. Go to this page and download the library: Download locomotivemtl/charcoal-contrib-filepond library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

locomotivemtl / charcoal-contrib-filepond example snippets


    $action = new RequestAction([
        'logger'          => $container['logger'],
        'filePondService' => $container['file-pond/service']($serverIdent),
    ]);
    



// From 'charcoal-contrib-filepond'
use Charcoal\FilePond\Service\Helper\FilePondAwareTrait;

/**
 * Create a new instructor.
 */
class SomeAction extends AbstractAction
{
    use FilePondAwareTrait;

    /**
     * Inject dependencies from a DI Container.
     *
     * @param Container $container A Pimple DI service container.
     * @return void
     */
    public function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->setFilePondService($container['file-pond/service']('private'));
    }
}

/**
 * Attempts to handle the transfer of uploads given the proper parameters.
 * If possible, it will try to :
 * - fetch the upload path from the property.
 * - fetch the filesystem based on the public access of the property.
 * - Pass it through the best processor depending on wether their were ids passed or not.
 *
 * @param string|array|null             $ids        The uploaded files ids. Let to null to force $_FILES and $_POST.
 * @param string|PropertyInterface|null $property   The property ident or a property.
 * @param ModelInterface|string|null    $context    The context object as model or class ident.
 * @param string|null                   $pathSuffix Path suffix.
 * @return array
 */
protected function handleTransfer(
    $ids = null,
    $property = null,
    $context = null,
    $pathSuffix = null
)

/** Transfer uploaded files */
$files = $this->handleTransfer(
    $submissionData['someProp'],
    'some_prop',
    $someModel,
    $someModel->property('id')->autoGenerate()
);