Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

cpereiramt

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

Recommended Posts

                   Olá, estou tentando criar um componente personalizado para visual composer um dropdown, tenho o arquivo php pesquisa.php que cria o componente personalizado,  e tenho o arquivo Receita.php que retorna os dados para serem exibidos no componente, o problema é que quando executo a pagina não aparece o componente e nem os dados do arquivo Receita.php.

                   Pelo DEBUG do Wordpress apresenta a seguinte mensagem abaixo:

 

[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
                   Por fim segue o conteúdo dos arquivos PHP mencionados : 

Pesquisa.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',
]);

?>

 

Receita.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;

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por violin101
      Caros amigos, saudações.
       
      Por favor, me permita tirar uma dúvida com os amigos.

      Tenho um Formulário onde o Usuário digita todos os Dados necessários.

      Minha dúvida:
      --> como faço após o usuário digitar os dados e salvar, o Sistema chamar uma Modal ou mensagem perguntando se deseja imprimir agora ?

      Grato,
       
      Cesar
    • Por Carcleo
      Tenho uma abela de usuarios e uma tabela de administradores e clientes.
      Gostaria de uma ajuda para implementar um cadastro
       
      users -> name, login, passord (pronta) admins -> user_id, registratiom, etc.. client -> user_id, registratiom, etc...
      Queria ajuda para extender de user as classes Admin e Client
      Olhem como estáAdmin
      <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Admin extends User {     use HasFactory;            protected $fillable = [         'name',         'email',         'password',         'registration'     ];      private string $registration;     public function create(         string $name,          string $email,          string $password,         string $registration     )     {         //parent::create(['name'=>$name, 'email'=>$email, 'password'=>$password]);         parent::$name = $name;         parent::$email = $email;         parent::$password = $password;         $this->registration = $registration;     } } User
      <?php namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class User extends Authenticatable {     /** @use HasFactory<\Database\Factories\UserFactory> */     use HasFactory, Notifiable;     static string $name;     static string $email;     static string $password;     /**      * The attributes that are mass assignable.      *      * @var list<string>      */     protected $fillable = [         'name',         'email',         'password',     ];          /**      * The attributes that should be hidden for serialization.      *      * @var list<string>      */     protected $hidden = [         'remember_token',     ];     /**      * Get the attributes that should be cast.      *      * @return array<string, string>      */     protected function casts(): array     {         return [             'email_verified_at' => 'datetime',             'password' => 'hashed',         ];     }          public function roles() : BelongsToMany {         return $this->belongsToMany(Role::class);     }       public function hasHole(Array $roleName): bool     {                 foreach ($this->roles as $role) {             if ($role->name === $roleName) {                 return true;             }         }         return false;     }         public function hasHoles(Array $rolesName): bool     {                 foreach ($this->roles as $role) {             foreach ($rolesName as $rolee) {             if ($role->name === $rolee) {                 return true;             }          }         }         return false;     }         public function hasAbility(string $ability): bool     {         foreach ($this->roles as $role) {             if ($role->abilities->contains('name', $ability)) {                 return true;             }         }         return false;     }     } Como gravar um Admin na tabela admins sendo que ele é um User por extensão?
      Tentei assim mas é claro que está errado...
      public function store(Request $request, Admin $adminModel) {         $dados = $request->validate([             "name" => "required",             "email" => "required|email",             "password" => "required",             "registration" => "required"         ]);         $dados["password"] =  Hash::make($dados["password"]);                  $admin = Admin::where("registration",  $dados["registration"])->first();                  if ($admin)              return                    redirect()->route("admin.new")                             ->withErrors([                                 'fail' => 'Administrador já cadastrados<br>, favor verificar!'                   ]);                            $newAdmin = $adminModel->create(                                    $dados['name'],                                    $dados['email'],                                    $dados['password'],                                    $dados['registration']                                 );         dd($newAdmin);         $adminModel->save();         //$adminModel::create($admin);                  return redirect()->route("admin.new")->with("success",'Cadastrado com sucesso');     }  
    • Por violin101
      Caros amigos, saudações.
       
      Gostaria de tirar uma dúvida com os amigos, referente a PDV.
       
      Estou escrevendo um Sistema com Ponto de Vendas, a minha dúvida é o seguinte, referente ao procedimento mais correto.

      Conforme o caixa vai efetuando a venda, o Sistema de PDV já realiza:
      a baixa direto dos produtos no estoque
      ou
      somente após concretizar a venda o sistema baixa os produtos do estoque ?
       
      Grato,
       
      Cesar
       
    • Por violin101
      Caros amigos do grupo, saudações e um feliz 2025.
       
      Estou com uma pequena dúvida referente a Teclas de Atalho.

      Quando o Caps Lock está ativado o Comando da Tecla de Atalho não funciona.
      ou seja:
      se estiver para letra minúscula ====> funciona
      se estiver para letra maiúscula ====> não funciona
       
      Como consigo evitar essa falha, tanto para Letra Maiúscula quanto Minúscula ?

      o Código está assim:
      document.addEventListener( 'keydown', evt => { if (!evt.ctrlKey || evt.key !== 'r' ) return;// Não é Ctrl+r, portanto interrompemos o script evt.preventDefault(); });  
      Grato,
       
      Cesar
    • Por violin101
      Caros amigos, saudações.
       
      Por favor, poderiam me ajudar.

      Estou com a seguinte dúvida:
      --> como faço para para implementar o input código do produto, para quando o usuário digitar o ID o sistema espera de 1s a 2s, sem ter que pressionar a tecla ENTER.

      exemplo:
      código   ----   descrição
           1       -----   produto_A
       
      Grato,
       
      Cesar
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.