2017 © Pedro Peláez
 

typo3-cms-extension configuration-object

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

image

romm/configuration-object

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  • Wednesday, January 24, 2018
  • by Romm
  • Repository
  • 1 Watchers
  • 5 Stars
  • 8,678 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 30 Versions
  • 10 % Grown

The README.md

Configuration Object Configuration Object

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads SensioLabs Insight StyleCI, (*1)

:heavy_exclamation_mark: This PHP library has been developed for TYPO3TYPO3 CMS and is intended to TYPO3 extension developers., (*2)

:arrow_right: You can find the whole documentation on the TYPO3 official website, or even download the :link:PDF version., (*3)


Introduction

Configuration Object Configuration Object provides powerful tools for handling configuration trees, by converting any configuration plain array (which can come from sources like TypoScript, JSON, XML) into a much more flexible PHP object structure. Its principal goal is to pull apart the configuration handling from the main logic of an application, so the script can focus on using the already validated configuration during its whole process., (*4)

Problem

When a script uses a configuration tree to handle parts of an application, this tree is often analyzed step by step during the script execution; if a value contains a mistake, the script can be forced to stop, too early (the whole process did not run entirely) but also too late (some sensitive operations may already have run). Moreover, the deeper the configuration tree is, the harder it is to handle and prevent all the possible configuration mistakes., (*5)

When it comes to configuration which may be customized by any third-party user (which happens often in TYPO3 thanks to TypoScript), validation rules have to be well thought and strong to prevent the user from breaking your own API scripts because of a configuration mistake., (*6)

Solution

Use Configuration Object to export the handling of your configuration: let the whole creation and validation processes be managed outside of your application, and enjoy the many other features provided by the API (cache management, parents, persistence and more)., (*7)

It is simple, fast and reliable., (*8)

Example

Imagine you have this configuration array:, (*9)

$myCompany = [
    'name'      => 'My Company',
    'employees' => [
        [
            'name'   => 'John Doe',
            'gender' => 'Male',
            'email'  => 'john.doe@my-company.com'
        ],
        [
            'name'   => 'Jane Doe',
            'gender' => 'Female',
            'email'  => 'jane.doe@my-company.com'
        ]
    ]
];

While this example is quite simple, it allows us to understand easily how this API works., (*10)

Below stands an example of how this configuration could look like using Configuration Object API., (*11)

You can see that two services are used:, (*12)

  • Cache service, (*13)

    It will store the whole company object, and its sub-objects, in a cache entry after they have been created. This will improve performances for next times the object must be fetched., (*14)

  • Parents service, (*15)

    With this service, the class Employee is able to retrieve the data from its parent (the class Company). In this example, we use it to dynamically generate an email address for the employee, if none was assigned., (*16)

namespace MyVendor\MyExtensions\Company;

use Romm\ConfigurationObject\ConfigurationObjectInterface;
use Romm\ConfigurationObject\Traits\ConfigurationObject\DefaultConfigurationObjectTrait;
use Romm\ConfigurationObject\Traits\ConfigurationObject\MagicMethodsTrait;
use MyVendor\MyExtensions\Model\Company\Employee;

class Company implements ConfigurationObjectInterface
{
    use DefaultConfigurationObjectTrait;
    use MagicMethodsTrait;

    const CACHE_NAME = 'cache_company';

    /**
     * @var string
     * @validate NotEmpty
     */
    protected $name;

    /**
     * @var \ArrayObject<MyVendor\MyExtensions\Company\Employee>
     */
    protected $employees;

    /**
     * @return ServiceFactory
     */
    public static function getConfigurationObjectServices()
    {
        return ServiceFactory::getInstance()
            ->attach(ServiceInterface::SERVICE_CACHE)
            ->setOption(CacheService::OPTION_CACHE_NAME, self::CACHE_NAME)
            ->attach(ServiceInterface::SERVICE_PARENTS);
    }
}

namespace MyVendor\MyExtensions\Company;

use Romm\ConfigurationObject\Service\Items\Parents\ParentsTrait;
use Romm\ConfigurationObject\Traits\ConfigurationObject\MagicMethodsTrait;

class Employee
{
    use ParentsTrait;
    use MagicMethodsTrait;

    /**
     * @var string
     * @validate NotEmpty
     */
    protected $name;

    /**
     * @var string
     * @validate NotEmpty
     * @validate Romm.ConfigurationObject:HasValues(values=Male|Female)
     */
    protected $gender;

    /**
     * @var string
     * @validate EmailAddress
     */
    protected $email;

    /**
     * Returns the email of the employee.
     *
     * If the email was not registered, a default one is assigned to
     * him, based on its name and its company name.
     *
     * Example: `John Doe` of the company `My Company` will be assigned
     * the default email: `john.doe@my-company.com`.
     *
     * @return string
     */
    public function getEmail()
    {
        if (null === $this->email
            && $this->hasParent(Company::class)
        ) {
            $sanitizedEmployeeName = SomeUtility::sanitizeStringForEmail($this->getName());

            $company = $this->getParent(Company::class);
            $sanitizedCompanyName = SomeUtility::sanitizeStringForEmail($company->getName(), '-');

            $this->email = vprintf(
                '%s@%s.com',
                [$sanitizedEmployeeName, $sanitizedCompanyName]
            );
        }

        return $this->email;
    }
}

The Versions

24/01 2018

dev-master

9999999-dev

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/01 2018

1.10.1

1.10.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/01 2018

dev-development

dev-development

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

02/12 2017

1.10.0

1.10.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

02/12 2017

dev-staging/1.10.0

dev-staging/1.10.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

08/11 2017

dev-feature/file-exists-validator

dev-feature/file-exists-validator

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

26/10 2017

dev-task/default-cache-group

dev-task/default-cache-group

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/09 2017

dev-feature/icon-exists-validator

dev-feature/icon-exists-validator

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

22/09 2017

dev-tmp

dev-tmp

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/08 2017

dev-wip/mixed-types-validation

dev-wip/mixed-types-validation

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

14/05 2017

1.9.0

1.9.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

03/05 2017

1.8.0

1.8.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

08/04 2017

1.7.0

1.7.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

29/03 2017

1.6.1

1.6.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

13/03 2017

1.6.0

1.6.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

09/03 2017

1.5.2

1.5.2.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

03/03 2017

1.5.1a

1.5.1.0-alpha

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

03/03 2017

1.5.1

1.5.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

27/02 2017

1.5.0

1.5.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

21/02 2017

1.4.0

1.4.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

14/02 2017

1.3.1

1.3.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

13/02 2017

1.3.0

1.3.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Romain Canon

configuration model typo3 object

30/01 2017

1.2.3

1.2.3.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

17/12 2016

1.2.2

1.2.2.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

06/10 2016

1.2.1

1.2.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

04/10 2016

1.2.0

1.2.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

08/09 2016

1.1.0

1.1.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/08 2016

1.0.2

1.0.2.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/08 2016

1.0.1

1.0.1.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object

24/08 2016

1.0.0

1.0.0.0

Transform any configuration plain array into a dynamic and configurable object structure, and pull apart configuration handling from the main logic of your script. Use provided services to add more functionality to your objects: cache, parents, persistence and much more.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.5

 

The Development Requires

by Romain Canon

configuration model typo3 object