PHPackages                             bfg/object - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. bfg/object

ActiveBfg-app

bfg/object
==========

To work with objects and arrays

0.0.4(1y ago)157.3k—8.7%15MITPHPPHP &gt;=8.0.0

Since Jul 14Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bfg-s/object)[ Packagist](https://packagist.org/packages/bfg/object)[ RSS](/packages/bfg-object/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (5)

Extension object
================

[](#extension-object)

To work with objects and arrays.

GAG Object
----------

[](#gag-object)

The Gag object is designed for recursive data filling and the construction of circuits and its children from the repartition that can be automatically filling. Standard Gag Object connects all classes in the `app/Gags` folder, all the classes are parsed there automatically fall into the Gag storage.

By default, there is already a harvested Gag object `Bfg\Object\Gag`which you can use globally for your needs. There is also the opportunity to create its own Gag collection.

Consider the situation with the filling of the standard GAG object:

```
\Bfg\Object\Gag::register('gag_name', MyComponent::class);
\Bfg\Object\Gag::register('gag_next', MyNextComponent::class);
```

Implementation methods:

```
public function gag(\Bfg\Object\Gag $gag)
{
    $gag->gag_name(...$construct_arguments)
        ->before(function (...$construct_arguments) {})
        // "before" To call an event before initialization.
        ->then(function (MyComponent $component, ...$construct_arguments) {})
        // "then" To call an event after initialization.
        ->gag_next();

    return $gag;
}
```

And the initializer will enter it:

```
\Bfg\Object\Gag::instance(MyComponent::class, function (
    MyComponent $component, array $child, ...$construct_arguments
) {
    return $component->applyChilds($child);
});
```

If you need to wrap in the GAG already ready component and there is no possibility to overload or replace it, then you can, I added a wrapper for such cases, to the priment, helper `view` is organized through such a wrapper:

```
