Error must take exactly 2 arguments - PHP / Wordpress / visual composer

0
Hello, I'm trying to create a custom component for visual composer a dropdown, I have the php file search.php that creates the custom component, and I have the file Recipe.php that returns the data to be displayed in the component, the problem is that when I run the page does not appear the component nor the data of the file Recipe.php.

From the DEBUG of Wordpress it presents the following message below:

 [03-Feb-2018 02:33:07 UTC] PHP Fatal error:  Method ImmutableValueObject::__set() must take exactly 2 arguments in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/Receita.php on line 33

Finally follows the contents of the mentioned PHP files:

Search.php

    <?php
include 'Receita.php'; 

class Pesquisa extends WPBakeryShortCode
{  

}

$atts = Integration::instance()->get_default_shortcode_attrs();
vc_map([
    'name' => __('N2Go Integrations', 'js_composer'),
    'base' => 'n2go_integrations',
    'icon' => 'icon-heart',
    'category' => [__('Content', 'js_composer')],
    'params' => array_map(


        function($key, $default){
            return [
                'type' => 'Dropdown',
                'heading' => ucwords(str_replace('_', ' ', $key)),
                'param_name' => $key,
                'value' => $default,
            ];
        },
        array_keys($att),
        $atts
    ),
    'descrição' => 'alguma descrição',
]);

?>

Recipe.php

    <?php

/**
 * Utility base class that makes it easier to fill in readonly value objects.
 * @internal
 */
abstract class ImmutableValueObject
{
    protected $data = [];

    final public function __construct(array $properties = [])
    {
        $this->data = array_merge($this->data, $properties);
    }

    final public function __get($name)
    {
        if (!array_key_exists($name, $this->data)) {
            throw new RuntimeException(sprintf('Undefined property: %s::%s', __CLASS__, $name));
        }

        return $this->data[$name];
    }

    final public function __set($name)
    {
        throw new RuntimeException(sprintf(
            '%s property: %s::%s',
            array_key_exists($name, $this->data) ? 'Readonly' : 'Undefined',
            __CLASS__,
            $name
        ));
    }
}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the integration
 * @property string $name Full name of integration, eg; 'WordPress'
 * @property string $abbreviation Short code of integration, eg; 'MAG' for Magento or 'WP' for WordPress
 * @property string $imageUrl Logo of the integration, usually in SVG format
 * @property string $helpUrl User guide URL - can be empty, in which case disable or hide help link
 * @property string $type A value from: 'CRM', 'CMS' or 'Webshop'
 * @property IntegrationSystem[] $items List of supported integrations (plugins or connectors bound to one system)
 */
class Integration extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the integration system
 * @property string $edition Eg; 'v4.2', 'v3 and older' or 'All Versions' - used in combination with integration
 * @property int $position Used for ordering
 * @property IntegrationPlugin[] $plugins List of plugins that support this edition.
 * @property IntegrationConnector[] $connectors List of connectors that support this edition.
 */
class IntegrationSystem extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the plugin
 * @property string $version Eg; '4000' or '4.0.0.0' - if it is 4 chars and no dots, then it should be formatted with dots between each char.
 * @property string $url Full URL for download the plugin. This may be a direct download or a page showcasing the plugin in a marketplace.
 */
class IntegrationPlugin extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the connector
 * @property string $version Eg; '4000' or '4.0.0.0' - if it is 4 chars and no dots, then it should be formatted with dots between each char.
 */
class IntegrationConnector extends ImmutableValueObject {}

/** @var Integration[] $sampleData */
$sampleData = [
    new Integration([
        'id' => '1',
        'name' => 'Amazon',
        'abbreviation' => 'AM',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/amazon.svg',
        'helpUrl' => 'https://www.newsletter2go.de/features/amazon-newsletter-integration/',
        'type' => 'Webshop',
        'items' => [
            new IntegrationSystem([
                'id' => '1',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [],
                'connectors' => [
                    new IntegrationConnector(['id' => '1', 'version' => '3000']),
                ],
            ])
        ]
    ]),
    new Integration([
        'id' => '2',
        'name' => 'Lightspeed eCom',
        'abbreviation' => 'LS',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/lightspeed.svg',
        'helpUrl' => '',
        'type' => 'Webshop',
        'items' => [
            new IntegrationSystem([
                'id' => '2',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [],
                'connectors' => [
                    new IntegrationConnector(['id' => '2', 'version' => '3000']),
                    new IntegrationConnector(['id' => '3', 'version' => '3001']),
                    new IntegrationConnector(['id' => '4', 'version' => '3002']),
                    new IntegrationConnector(['id' => '5', 'version' => '3003']),
                ],
            ])
        ]
    ]),
    new Integration([
        'id' => '3',
        'name' => 'WordPress',
        'abbreviation' => 'WP',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/wordpress.svg',
        'helpUrl' => 'https://www.newsletter2go.com/help/integration-api/set-up-wordpress-plug-in/',
        'type' => 'CMS',
        'items' => [
            new IntegrationSystem([
                'id' => '2',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [
                    new IntegrationPlugin(['id' => '1', 'version' => '2100', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v2_1_00.zip']),
                    new IntegrationPlugin(['id' => '2', 'version' => '3000', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_00.zip']),
                    new IntegrationPlugin(['id' => '3', 'version' => '3003', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_03.zip']),
                    new IntegrationPlugin(['id' => '4', 'version' => '3005', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_05.zip']),
                    new IntegrationPlugin(['id' => '5', 'version' => '4006', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_latest.zip']),
                ],
                'connectors' => [
                    new IntegrationConnector(['id' => '6', 'version' => '3000']),
                ],
            ])
        ]
    ]),
];

return $sampleData;
    
asked by anonymous 04.02.2018 / 17:30

0 answers