2017 © Pedro Peláez
 

library filer-common

Flash applicative filer - common components

image

fei/filer-common

Flash applicative filer - common components

  • Thursday, June 7, 2018
  • by rwellens
  • Repository
  • 21 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 16 Versions
  • 25 % Grown

The README.md

Filer Common

GitHub license continuousphp Build Status GitHub issues, (*1)

This is the Filer Common elements package which contains:, (*2)

  • File Entity and transformer
  • File Entity validator
  • Context Entity and transformer
  • Context Entity validator
  • Related classes

Installation and Requirement

Filer Client needs PHP 5.5 or higher., (*3)

Add this requirement to your composer.json: "fei/filer-common": : "^1.0", (*4)

Or execute composer.phar require fei/filer-common in your terminal., (*5)

Usage

Entities and classes

File entity

In addition to traditional ID and CreatedAt fields, File Entity has six important properties:, (*6)

Property Type
uuid string
revision integer
category integer
contentType string
data string
filename string
file SplFileObject
contexts ArrayCollection
  • $uuid (Universal Unique Identifier) is a unique id corresponding to a file. Its format is based on 36 characters as defined in RFC4122 prefixed by a backend id and separated by a :. Example: bck1:f6461366-a414-4b98-a76d-d7b190252e74
  • revision is an integer indicating the file's current revision.
  • category is an integer defining in which database the file will be stored in.
  • contentType defines the content type of the File object.
  • data contains the file's content.
  • filename contains the file's filename.
  • file is an SplFileObject instance. (see https://secure.php.net/manual/en/class.splfileobject.php for more details)
  • contexts is an ArrayCollection instance where each element is a Context entity

Context entity

In addition to traditional ID field, Context Entity has three important properties:, (*7)

Property Type
key string
value string
file File
  • key is a string defining the context's key.
  • value is a string defining the context's value
  • file is a File object indicating the context's related file

Other tools

File validator

You have the possibility to validate a File entity with FileValidator class:, (*8)

<?php

use Fei\Service\Filer\Validator\FileValidator;
use Fei\Service\Filer\Entity\File;

$fileValidator = new FileValidator();
$file = new File();

//validate returns true if your File instance is valid, or false in the other case
$isFileValid = $fileValidator->validate($file);

//getErrors() allows you to get an array of errors if there are some, or an empty array in the other case
$errors = $fileValidator->getErrors();

By default, all File properties must not be empty, but you're also able to validate only a few properties of your entity, using validate methods:, (*9)

<?php

use Fei\Service\Filer\Validator\FileValidator;
use Fei\Service\Filer\Entity\File;

$fileValidator = new FileValidator();

$file = new File();
$file->setUuid('uuid');
$file->setRevision(1);

$fileValidator->validateUuid($file->getUuid());
$fileValidator->validateRevision($file->getRevision());

// will return an empty array : all of our definitions are correct
$errors = $fileValidator->getErrors();
echo empty($errors); // true

// contentType can not be empty, let's try to set it as an empty string
$file->setContentType('');
$fileValidator->validateContentType($file->getContentType());

// this time you'll get a non-empty array
$errors = $fileValidator->getErrors();

echo empty($errors); // false
print_r($errors);

/**
* print_r will return:
*
*    Array
*    (
*        ['contentType'] => Array
*            (
*                'Content-Type cannot be empty'
*            )
*    )
**/

Context validator

You have the possibility to validate a Context entity with ContextValidator class:, (*10)

<?php

use Fei\Service\Filer\Validator\ContextValidator;
use Fei\Service\Filer\Entity\File;
use Fei\Service\Filer\Entity\Context;

$contextValidator = new ContextValidator();
$file = new File();
$context = new Context([
    'key' => 'my_key',
    'value' => 'my_value',
    'file' => $file
]);

//validate returns true if your Context instance is valid, or false in the other case
$isContextValid = $contextValidator->validate($context);

//getErrors() allows you to get an array of errors if there are some, or an empty array in the other case
$errors = $contextValidator->getErrors();

By default, all Context properties must not be empty, but you're also able to validate only a few properties of your entity, using validate methods:, (*11)

<?php

use Fei\Service\Filer\Validator\ContextValidator;
use Fei\Service\Filer\Entity\Context;

$contextValidator = new ContextValidator();
$context = new Context();
$context->setKey('key');
$context->setValue('value');

$contextValidator->validateKey($context->getKey());
$contextValidator->validateValue($context->getValue());

// will return an empty array : all of our definitions are correct
$errors = $contextValidator->getErrors();
echo empty($errors); // true

The Versions

07/06 2018

dev-master

9999999-dev

Flash applicative filer - common components

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

filer

07/06 2018

v1.1.3

1.1.3.0

Flash applicative filer - common components

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

filer

25/05 2018

v1.1.2

1.1.2.0

Flash applicative filer - common components

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

filer

17/05 2018

dev-feature/update_composer_url

dev-feature/update_composer_url

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

22/03 2018

v1.1.1

1.1.1.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

06/12 2017

dev-develop

dev-develop

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

06/12 2017

v1.1.0

1.1.0.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

05/10 2017

v1.0.8

1.0.8.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

31/08 2017

v1.0.7

1.0.7.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

03/08 2017

v1.0.6

1.0.6.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

01/08 2017

v1.0.5

1.0.5.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

15/03 2017

v1.0.4

1.0.4.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

13/03 2017

v1.0.3

1.0.3.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

14/02 2017

v1.0.2

1.0.2.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

30/01 2017

v1.0.1

1.0.1.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer

25/01 2017

v1.0.0

1.0.0.0

Flash applicative filer - common components

  Sources   Download

The Requires

 

The Development Requires

by Boris Cerati
by Vincent Simonin

filer