Error 'Undefined property: ImmutableValueObject :: data' - PHP / WORDPRESS / VISUAL COMPOSER

0

Hello, there is an error that I can not solve, I'm creating a custom component for the visual composer, follow the log below:

    [05-Feb-2018 12:00:35 UTC] PHP Warning:  array_merge(): Argument #1 is not an array in /var/www/html/wp-content/plugins/searchwp/searchwp.php on line 466
[05-Feb-2018 12:00:35 UTC] PHP Strict Standards:  Redefining already defined constructor for class wp_memory_usage in /var/www/html/wp-content/plugins/wp-memory-usage/wp-memory-usage.php on line 39
[05-Feb-2018 12:00:36 UTC] PHP Notice:  Undefined variable: data in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php on line 15
[05-Feb-2018 12:00:36 UTC] PHP Warning:  array_merge(): Argument #1 is not an array in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php on line 15
[05-Feb-2018 12:00:36 UTC] PHP Warning:  array_key_exists() expects exactly 2 parameters, 1 given in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php on line 20
[05-Feb-2018 12:00:36 UTC] PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Undefined property: ImmutableValueObject::data' in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php:21
Stack trace:
#0 /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php(28): ImmutableValueObject->__get('data')
#1 /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php(15): ImmutableValueObject->__set('data', NULL)
#2 /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php(89): ImmutableValueObject->__construct(Array)
#3 /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/n2go-integrations.php(2): include('/var/www/html/w...')
#4 /var/www/html/wp-content/themes/n2go-2014/functions.php(465): require_once('/var/www/html/w...')
#5 /var/www/html/wp-settings.php(329): include('/var/www/html/w...')
#6 /var/www/html/wp-config.php(109): require_once('/var/www/html/w...')
#7 /var/www/html/wp-load.php(29): require_once( in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/download-center.php on line 21

Below are the php files: download-center.php

<?php

/**
 * Utility base class that makes it easier to fill in readonly value objects.
 * @internal
 */


abstract class ImmutableValueObject
{
 public static $data = array();
 public $name = array();
    final public function __construct( $properties = array())
    {  
        $this->data=array_merge($data,$properties);
    }

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

        return $name;
    }

    final public function __set($name,$data)
    {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;

n2go-integrations.php

n2go_integrations 
<?php
include 'download-center.php'; 

class N2GO_Integrations extends WPBakeryShortCode
{  

}
 $data = array();
$atts = Integration::$data->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($atts),
        $atts
    ),
    'description' => 'some description',

]);

?>
    
asked by anonymous 05.02.2018 / 13:18

0 answers