enriquepiatti / Magicento

PHPStorm plugin for Magento developers
115 stars 36 forks source link

[Magento2] Add generation of getters/setters for API. #286

Open Koc opened 6 years ago

Koc commented 6 years ago

http://inchoo.net/magento-2/magento-2-custom-api/

Consider we have an interface for API

<?php

namespace Brouzie\Satin\Api\Data;

interface ContactFormMessageInterface
{
    const NAME = 'name';

    const EMAIL = 'email';

    const PHONE = 'phone';

    const MESSAGE = 'message';

    const URL = 'url';
}

Would be nice if Magicento allows generate getters/setters for constants:

    public function getName(): string;

    public function setName(string $name);

And model class with implementation of this getters/setters:

    public function getProductId(): int
    {
        return $this->getData(self::PRODUCT_ID);
    }

    public function setProductId(int $productId)
    {
        return $this->setData(self::PRODUCT_ID, $productId);
    }

With proper phpdocs, of course.

alexbejan-mavfarm commented 4 years ago

Is there an update on this?

yohanespradono commented 4 months ago

I wrote a little python script to generate Interface files and the implemenation class files. https://github.com/yohanespradono/magento-service-data-generator

It doesn't generate from an interface but instead it uses a yaml file.